NinethSense oWnZ mE!: Praveen’s drawing book

Choose a Topic:

Tue
7
Nov '06

Windows Logger with VBS

This is a quick script from my hands which logs the date and time of windows ‘loging’ and ‘logoff’.

 
dim objfso, objtextfile
 
set objfso = CreateObject(“Scripting.FileSystemObject”)
set objtextfile = objfso.OpenTextFile(“f:\logsystem.txt”,8,True)
 
if WScript.Arguments(0) = “LOGIN” then 
	objtextfile.Write(vbCrLf & Date & ” “ & Time)
else
	objtextfile.Write(” - “ & Time)
end if
	
objTextFile.Close
Wscript.Quit
The output will be like:
11/7/2006 4:15:25 PM - 4:15:27 PM
11/7/2006 4:15:31 PM - 4:15:32 PM
11/7/2006 4:15:34 PM - 4:15:35 PM
11/7/2006 4:15:36 PM
To configure the script in your system you may use “gpedit.msc”. Under “User Configuration” -> “Windows Settings” -> “Scripts(Logon/Logoff)”.

This is the syntax:
[filename .vbs] LOGIN
[filename .vbs] LOGOFF
The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website