DisplayUserVersionLGPO.vbs.txt

(1 KB) Pobierz
'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

 

objTS.Close

 

 

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
   'The machine version number is always the lower half of the number.
   'The user version number is always the upper half of the number.
   'When converted to a hexadecimal number, the machine version will be displayed
   'in the first 4 hexadecimal characters.  The user version number will be the
   'remaining top hexadecimal characters past the lower 4 hexadecimal numbers.

   'After converting the combined version number to hexadecimal first find the
   'number of hexadecimal numbers being used for the user version number.
   'Then take all the left hand hexadecimal number strings for the user number.
   'Then convert it back to an integer number.

   userVerLen = Len(Hex(arrResults(1))) - 4

   userVersion = Cint("&H" & Left(Hex(arrResults(1)),userVerLen))
 
   wScript.Echo "user version number = " & userVersion

   
Next
Zgłoś jeśli naruszono regulamin