Tracking User Logins with Login/Logoff Scripts

Hi ;
Even though we can use event viewer for this; there is a nice way to keep a track of the Remote Desktop Logins using a little script;

In order to do so :

1. Log in to your server & Write the following bat script on :

c:\Reporting\logon.bat( Create folder & file )


with the following code:

Login Code
Echo %date%,%time%,%username%,%computername% >> C:\Reporting\Logons.txt

Logoff Code

Echo LOGOFF,%date%,%time%,%username%,%computername% >> "C:\Reporting\%username%.log

As you can see this would be the output;

2018-11-22 13_38_13-Window.png

2.Use Local Group Policy to run the scripts ( OR Group Policy )

2018-11-22 13_42_11-Window.png

3.Copy your Scripts on


4. Reboot the server and check the files if are working;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.