Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate Log File for PC Log-In and Log-Off time

Status
Not open for further replies.

Nu2Java

Technical User
Jun 5, 2012
166
US
Hello... Does anyone know of a vbscript that will create an appending log file to record (login-Date/Time and logoff-Date/Time? The script would run on the local PC.

Thanks
 
A simple script that opens a file for append an writes the date. The tricky part will be getting GPO to work. You can push a logon and logoff script using GPO.

If it's just one computer, simply put the script in the startup folder. Logoff is a little more difficult. I'm not aware of an easy method to instanciate a logoff script.

Code:
set objFSO = CreateObject("Scripting.FileSystemObject")
set objLog = objFSO.OpenTextFile("c:\log.txt", 8, true, 0)
set objNetwork = CreateObject("WScript.Network")

objLog.WriteLine objNetwork.ComputerName & " - " & objNetwork.UserName & " - " & date
objLog.close

-Geate

 
Thanks, Geates. Would there be a way to run this on a timer? Like run this every 15 minutes. I am trying to find out what the uptime is on a few PC's.
 
Thanks to ALL of you for the help .... I think this gets me going in the right direction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top