JSI Tip 4543. A better way to determine who is logged onto the console of a remote computer


In tip 1211 ยป Who is logged on locally, we used Windows commands to determine who was logged onto the console of the specified computer.

Here is a VB script that I named WhoIsOn.vbs. It prompts for the computer name and returns a message box containing the logged on User Name:

ComputerName = InputBox("Enter the name of the computer you wish to query")
who = "winmgmts:\{impersonationLevel=impersonate\}!//"& ComputerName &""
Set Users = GetObject( who ).InstancesOf ("Win32_ComputerSystem")
for each User in Users
	MsgBox "The user name for the specified computer is: " & User.UserName
Next



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish