Simple User Logon Logoff Logging on a Windows Domain

I like simple scripts, and this one is so obvious – I wonder why I didn’t think of it:

First, create a folder on your server, and share it as logon$. Make sure that users are given read and write access in the share properties, and in the folder security settings.

Create the following logon scripts and add them to the logon / logoff scripts as appropriate. Both scripts are ONE LINE ONLY.

logon.cmd

echo logon,%COMPUTERNAME%,%USERNAME%,%DATE%,%TIME% >> \\server1\logon$\Logon.csv

logout.cmd

echo logoff,%COMPUTERNAME%,%USERNAME%,%DATE%,%TIME% >> \\server1\logon$\Logon.csv

Once done, you can load the file into a program such as Excel and easily manipulate the data to find what you are looking for.

Naturally, change the name server1 to your server name. It’s a simple way to log users accessing workstations so that you know who as logged on where.

I was considering doing the same with a database and VBscript – which would inevitably slow down the logon process. This should make things wonderfully simple.

I settled on keeping the log file the same for logons and logoffs, as it seems sensible to track these in the same file. If you seperate them and say, want to find out how long a user has been logged on for, then you have to start dealing with too many seperate files.

Creating a new default user profile

Changing the default user profile is not a particularly daunting task. In fact, my experiences show that in Windows 2000, XP and 2003, it’s a relatively painless experience.

  • Logged in as a local administrator, create a new user account.
  • Log out and log in as that user.
  • Log back in as an administrator.
  • Enable Show hidden files and folders
  • Go to the documents and settings folder on the system drive, and into the newly created user profile.
  • Copy the ntuser.dat file to the Default User folder, overwriting the existing profile.

That’s it! Of course, you can use the Microsoft friendly method instead if your OS supports it.