Vbscript / Operating System / Wmi Connect As Another User
Connect and perform WMI operations as another user.
strComputer = "server" strUser = "domain\administrator" strPassword = "123"
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer,"root\cimv2", strUser, strPassword)
Set colSwbemObjectSet = objSWbemServices.ExecQuery("Select * From Win32_Process") For Each objProcess in colSWbemObjectSet Wscript.Echo "Process Name: " & objProcess.Name Next
Please note that a disclaimer applies to any code on this page.
|