Dim colResults, objResult, strWMIQuery Dim objLocator, objWMI Dim objArgs Dim objNetwork Set objNetwork=CreateObject("WScript.Network") Set objArgs=WScript.Arguments Set objNamed=objArgs.Named If objNamed.Exists("S") Then strComputer=objNamed.Item("S") Else WScript.Echo "You failed to specify a computer name!" WScript.Echo "Example: cscript GetInfo.vbs /S:computername " &_ "[/U:domain\admin] [/P:password]" WScript.Quit End If If objNamed.Exists("U") Then strAdmin=objNamed.Item("U") If objNamed.Exists("P")="" Then WScript.Echo "You forgot to specify a password for " &_ strAdmin WScript.Quit Else strPassword=objNamed.Item("P") End If Else strAdmin="" strPassword="" End If If (strComputer="." Or UCase(strComputer)= _ UCase(objNetwork.ComputerName) Or _ UCase(strComputer)="LOCALHOST") And strAdmin<>"" Then WScript.Echo "You can't use alternate credentials " &_ "for local connections. Connecting with existing " &_ "credentials." strAdmin="" strPassword="" End If WScript.Echo "Connecting to " & strComputer Set objLocator = CreateObject("WbemScripting.SWbemLocator") Set objWMI = objLocator.ConnectServer( _ strComputer, "root\cimv2", strAdmin, strPassword) strWMIQuery = "SELECT * FROM Win32_OperatingSystem" Set colResults = objWMI.ExecQuery(strWMIQuery) For Each objResult In colResults WScript.echo "OS = " & objResult.Caption Next