Explain VBScript request WMI / imersonationLevel etc.

Dim strComputer, objReg, ScriptName, strKeyPath, strValueName, strValue
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

This is a piece of a larger script that I'm trying to rebuild to work. Source encoder unavailable.

I tried to research and understand the last line of code, but I cannot find any good information on the net, and I am not so good at vbs.

As far as I can tell: - objreg - an object of type SWbemObjectEx. - winmgmts: {impersonationLevel = impersonate} allows the object to use the caller's security level (on my system) - StdRegProv should point to HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ WBEM \ Scripting \ Default Impersonation Level

I kind of understand what he should do, but I don’t understand how he plays the game.

If someone can explain procedurally word for word what he is doing, including things like β€œ!”, I would really appreciate that. Thank.

+4
source share
1 answer

First of all, setting it strComputerequal to the period ( .), this means that it is aimed at the local computer and not at the remote computer, since this period is an abbreviation of MS Windows for the local computer.

GetObject() - Windows Scripting Host, , (. http://msdn.microsoft.com/en-us/library/8ywk619w%28v=vs.84%29.aspx ). Windows Management Instrumentation (WMI) Windows (. http://msdn.microsoft.com/en-us/library/aa394582%28v=vs.85%29.aspx WMI) WMI winmgmts: (. http://technet.microsoft.com/en-us/library/bb684728.aspx WMI).

WMI-, , WMI :

  • "winmgmts:" ()
  • ()
  • WMI ()

" ": {impersonationLevel=impersonate}!, " WMI": \\.\root\default:StdRegProv.

, , , .

WMI, , WMI. . \\<computer name>\, <computer name> , , .

StdRegProv (. http://msdn.microsoft.com/en-us/library/aa393664%28v=vs.85%29.aspx ); Windows .

Set objReg=GetObject("winmgmts:impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

objReg ( , . http://msdn.microsoft.com/en-us/library/aa393664%28v=vs.85%29.aspx ).

+9

Source: https://habr.com/ru/post/1535742/


All Articles