Get remote Windows environment variables

Argomenti vari di carattere sistemistico
Post Reply
daniele
Posts: 342
Joined: 04 Mar 2009, 13:59

Get remote Windows environment variables

Post by daniele »

Codice VBSCRIPT:
(

Code: Select all

 GetEnvironment("[RemoteServersName]")

Function GetEnvironment(ServerName)

    strComputer = ServerName
    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objSWbemServices = objSWbemLocator.ConnectServer _
        (strComputer, "root\cimv2", "[ValidLogonName]", "[PasswordForLogonName]")
    objSWbemServices.Security_.ImpersonationLevel = 3
    Set colVar = objSWbemServices.ExecQuery( _
        "Select * from Win32_Environment")
    For Each objVar in colVar
            WScript.StdOut.Write("Server Name: " & ServerName & VBNewLine)
            WScript.StdOut.Write("Description: " & objVar.Description & VBNewLine)
            WScript.StdOut.Write("Name: " & objVar.Name & VBNewLine)
            WScript.StdOut.Write("System Variable: " & objVar.SystemVariable & VBNewLine)
            WScript.StdOut.Write("User Name: " & objVar.UserName & VBNewLine)
            WScript.StdOut.Write("Variable Value: " & objVar.VariableValue & VBNewLine & VBNewLine)
    Next

End Function
Post Reply