Page 1 of 1

objWMIService.ExecQuery

Posted: Tue Feb 28, 2012 1:29 am
by milend1966
Hi, i need to run the script below:'On Error Resume NextstrComputer = "."Wscript.Echo "PC "&strComputer Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)For Each objItem in colItems Wscript.Echo "UserName: " & objItem.UserName NextMy problem is that on lab PC it works and returns the user logged on, on production PC it returns null value. The operative system is the same W2003 EE. I know that there are other ways to retrieve this information, but i need to know why objItem.UserName does not work always...thanks

objWMIService.ExecQuery

Posted: Tue Feb 28, 2012 3:37 am
by milend1966
I'm querying remotely by RDP....