Find last logged in USER in a remote computer from your network via Cmd Prompt

Imagine a scenario that you are monitoring network of offices situated at different global locations and you received a virus alert email saying that one of the computer in remote location is infected with Virus

If you can find the current user who is logged into the machine you can advise them to log off from their account and turn the machine OFF until the local network security team can investigate about the infection 

There are different tools like Lansweeper which can tell you the last logged in user in a remote computer.If you don't want to use such tools or if you are not allowed to install 3rd party tools  you can find the last logged in user in a remote computer in your network simply by running a batch file

Steps for creating the batch file

1.Open a Notepad
2.Type below text to a notepad

@echo off
echo This batch file is for finding the last user logged into a computer in your network.Please enter the IP address or Hostname of the computer below to find the last logged in USER for that particular computer

echo.
:Loop
set /p IP-or-HostName=Enter IP-or-HostName :
wmic.exe /node:%IP-or-HostName% ComputerSystem Get UserName
goto Loop

or download  batch file by clicking here  [You may get a warning from your Antivirus or chrome saying that file is Malicious ,You can ignore that because for all .cmd which was downloaded from internet you will get such warning!]

3.Save the notepad as FindUser.cmd and save it in your desktop

In future if you come across a situation to find the last logged in user in a remote computer.Just open the  FindUser.cmd batch file and provide the host name or IP address of the computer and it will show you the last user logged into that computer

Let me know if you face any trouble in creating this batch file



1 comment:

  1. while execute the batch file.access is denied error is appeared

    ReplyDelete