General discussion

Locked

Get currently logged on user of remote c

By twhite ·
I am trying to retrieve the User Name of the currently logged on user of a remote computer. I tried the following vbscript:
'***********************************
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?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Get currently logged on user of remote c

by Joseph Moore In reply to Get currently logged on u ...

I use a tool called NBTENUM ver 3 that does an enumeration of some information on a remote Windows machine. One of the pieces of info is the Logged On Users.
The web site for this tool is no longer operational, so you will have to search for it. You should be able to get it from Packetstorm.

hope this helps

Collapse -

Get currently logged on user of remote c

by ewgny In reply to Get currently logged on u ...

This excellent tool will work fast and easy
nbtscan.exe
http://www.unixwiz.net/tools/nbtscan.html
example
nbtscan 10.1.1.1-254 would scan 10.1.1.1 through
10.1.1.254 and list all computers and who is logged on to them.
This works great as long as NetBios over TCP/IP has not been disabled on the client PC

Collapse -

Get currently logged on user of remote c

by twhite In reply to Get currently logged on u ...

I think I figured it out, I had to add myself to the local Administrator group on the machine I was trying to call. Thanks to all who responded.

Back to Networks Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums