Displays the machine portion of the Local Group Policy Object version number as found in the GPT.ini file. Script contributed by Microsoft's Mike Stephens and Judith Herman.

Visual Basic
'First find the windows directory which can be different on each machine
Set wshshell = CreateObject("WScript.Shell")
windir = wshshell.ExpandEnvironmentStrings("%WINDIR%")

'Using the path relative to the windows directory look for the GPT.INI file
Set objFSO = CreateObject("Scripting.FileSystemObject")
filename = windir & "\SYSTEM32\GROUPPOLICY\GPT.INI"

Set objTS = objFSO.OpenTextFile("c:\windows\SYSTEM32\GROUPPOLICY\GPT.INI")
strFileContents = objTS.ReadAll

Set objRE = New RegExp

'Use the pattern of Carriage Return followed by the text "Version=" with other characters following.
'The characters following the = sign are expected to be numbers.

objRE.Pattern = "\nVersion=.+"
objRE.Global = True
objRE.IgnoreCase = False
Set colMatches = objRE.Execute(strFileContents)

For Each objMatch In colMatches
   strTmp = objMatch.Value
   arrResults = Split(strTmp,"=")

   'Value represents machine and user version numbers combined in one number
   'An easy way to get the machine version number is to convert the version number
   'to Hex and take the lower 4 characters representing machine version.
   'To convert back to decimal tack on the "&H" to the front of the number
   'and then convert back to integer.

   machineVersion = Cint( "&H" & Right(Hex(arrResults(1)), 4))
   wScript.Echo "machine version number = " & machineVersion