General discussion
Thread display: Collapse - |
All Comments
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Get currently logged on user of remote c
'***********************************
strComputer = "."
If WScript.Arguments.Count > 0 then
strComputer = WScript.Arguments(0)
End If
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,4
msg = ""
For Each objItem in colItems
msg = msg & "Domain: " & objItem.Domain & vbCRLF
msg = msg & "Manufacturer: " & objItem.Manufacturer & vbCRLF
msg = msg & "Model: " & objItem.Model & vbCRLF
msg = msg & "Name: " & objItem.Name & vbCRLF
msg = msg & "UserName: " & objItem.UserName & vbCRLF
NextWScript.Echo msg
'***********************************
If I run this script without arguments (local machine) I get the user name, but if I specify a remote computer name, the user name is not retrieved. Am I missing something? Is there an easier way to accomplish the same task?