web analytics

WMI+VBS: how to get the domain name

Option Explicit On Error Resume Next Dim strComputer, objNetwork, objWMIService Dim colItems, objItem Set objNetwork = WScript.CreateObject("WScript.Network") strComputer = objNetwork.ComputerName WScript.Echo "Computer = " & strComputer Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\"&strComputer&"\root\cimv2") Set colItems = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") For Each objItem in colItems  Wscript.Echo "Domain = " & objItem.domain Next

There is also WMI FAQ on Microsoft […]