Find the current logged on user on a remote machine
Tags:
It is always important for any IT helpdesk person to know the current logged-on user on a remote machine within a network. There are many softwares and tools available for purchase to do the same. But for smaller organizations, if they do not want to pay for such softwares they can write a script in VB or Javascript. The below script is written in VB.
How to use it ?
Copy this script and paste it on a notepad. Save it as username.vbs. Then double click on the saved file. It will ask you for the computer name on which you want to find the user who is logged on. Enter the computer name (hostname) and click ok. The program will display the name of the current logged on user.
strComputer=InputBox("Enter the computer name: ")
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

