If your in need of finding out who is logged on to a specific Windows PC on your network, run the VBScript below.
When executed, you’ll see a message box with the name of the account currently logged in the computer specified.

The VBScript Code
To use this code, copy it in to a text file and save it with a .vbs file extension for VBScript. Once you have the .vbs file, double click on it and you should get a message box with the names of the logged in user on the specified Windows PC on your network.
Function GetLoggedinUser(strComputer)
	Set objWMIService = GetObject("winmgmts:" _
		& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
	Set colComputer = objWMIService.ExecQuery _
		("Select * from Win32_ComputerSystem")
	 
	For Each objComputer in colComputer
		Wscript.Echo "Logged-on user: " & objComputer.UserName
	Next	
	
End Function
' Pass a . to run this on your own PC or add a string value name for PC on your network
'strComputer = "XPS1234"
strComputer = "."
call msgbox(GetLoggedinUser(strComputer))Stay tuned for more scripts in upcoming blog posts!
Hope this helps somebody!
~Cyber Abyss
 
					