Custom Search

Mar 20, 2009

Capture login time / logout time for users on any Windows PC using simple scripts

The following scripts can be used to track user login/logout activity on workstations or terminal servers. I have it set up to track just one PC, but you could easily adapt this script to monitor multiple workstations by removing the IF statement after "Set THENetwork . . . " line. If you do this, please do not forget to remove the "End IF" statement as well.

You need to personalize the BOLD/ITALIC statements to your environment.

I used a GPO to run these scripts at logon and logoff in our domain. I suggest you do the same. You need to create a network location that is accessible by everyone. You can set the folder permission to allow write but only allow administrators to list/read the location.

The output files are Comma Separated and can be easily opened by Microsoft Excel.


LoginReport.vbs

START SOURCE CODE

WriteLineToFile()

Function WriteLineToFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set THENetwork = WScript.CreateObject("WScript.Network")
IF (THENetwork.ComputerName = "CHANGE THIS TO THE COMPUTER YOU ARE MONITORING") Then
filename = "OUTPUT LOCATION" & THENetwork.UserName & ".csv"
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename, ForAppending, True)
qMark = Unescape("%22")
coma = Unescape("%2C")
today = date()
curTime = Time
username = THENetwork.UserName
computername = THENetwork.ComputerName
f.Writeline()
f.Write qMark & today & qMark & coma
f.Write qMark & username & qMark & coma
f.Write qMark & computername & qMark & coma
f.Write qMark & curTime & qMark & coma
Set f = fso.OpenTextFile(filename, ForReading)
WriteLineToFile = f.ReadAll
End IF
End Function

END SOURCE CODE



logoutReport.vbs

START SOURCE CODE

WriteLineToFile()

Function WriteLineToFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set THENetwork = WScript.CreateObject("WScript.Network")
IF (THENetwork.ComputerName = "CHANGE THIS TO THE COMPUTER YOU ARE MONITORING") Then
filename = "OUTPUT LOCATION" & THENetwork.UserName & ".csv"
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename, ForAppending, True)
qMark = Unescape("%22")
coma = Unescape("%2C")
today = date()
curTime = Time
username = THENetwork.UserName
computername = THENetwork.ComputerName
f.write qMark & curTime & qMark & coma
Set f = fso.OpenTextFile(filename, ForReading)
WriteLineToFile = f.ReadAll
End IF
End Function

END SOURCE CODE







Please leave me comments. Let me know if this worked for you, or if you notice something that needs to be changed. Use the Tell&Share icon under the title of the post to share it with your friends or digg it!

Mar 18, 2009

Can't remove additional Outlook mailboxes




USE THE REGISTRY EDITOR AT YOUR OWN RISK! YOU HAVE BEEN WARNED!

Here are the basic steps I used to correct the issue:

1) Run regedit to edit your windows registry.

2) Locate HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"Your outlook Profile"

3) Click on each sub-folder and open the 001f3001 keys to determine which folders are associated with each additional mailbox.

4) It's easy to spot the 'dangling' mailbox since you'll be able to spot the user's mailbox name in the registry key.

5) BEFORE PROCEEDING: I would backup the HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"Your outlook Profile" keys by exporting them to a safe location.

5) Delete the entire sub-folder of the key.

6) Re-Load outlook and the 'dangling' mailboxes should now be gone.






Please leave me comments. Let me know if this worked for you, or if you notice something that needs to be changed. Use the Tell&Share icon under the title of the post to share it with your friends or digg it!