objWMIService.ExecQuery

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 12 years and 4 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
milend1966
Posts: 7
Last visit: Tue Feb 28, 2012 2:37 am

objWMIService.ExecQuery

Post 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
User avatar
milend1966
Posts: 7
Last visit: Tue Feb 28, 2012 2:37 am

objWMIService.ExecQuery

Post by milend1966 »

I'm querying remotely by RDP....
This topic is 12 years and 4 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked