number34 Posted November 13, 2006 Posted November 13, 2006 We used Classlink and Ranger in the past but due to problems with both of them decided to move to regulating users actions by tailoring group policies in the AD ourselves (Win 2003 server in use). We have had few problems but have struggled to track users logging on and off PC's adequately. Unfortunately this has coincided with a major increase in the number of PC's the kids use and we are suffering more vandalism. I don't want to go back to Classlink or Ranger so does anyone have any suggestions? Thanks.
wesleyw Posted November 13, 2006 Posted November 13, 2006 I have a VB program I wrote that does this lists date time user computer ip etc to a set of files (Text) on a server share. If you have VB at your place it's easy enough to modify to use on your network? I am looking at sending it to a mdb but for now this suffices . Wes
Ric_ Posted November 14, 2006 Posted November 14, 2006 Another easy way that you can knock up in 5mins is two scripts. Firstly, a logon script... a simple batch file: echo %date%,%time%,logon,%computername%,%username% >> \\servername\sharename\logon.log Then a logoff script that contains: echo %date%,%time%,logoff,%computername%,%username% >> \\servername\sharename\logon.log This should give you the basic details. If you need more detail just add the variable names. If you use this regularly you will probably want something a bit more robust logging to a couple of servers and probably database-based.
Reaper Posted December 17, 2009 Posted December 17, 2009 Resurrecting an old thread! We have just decided to get right Ranger because of a consistent logon issue that hasn't been solved as yet. The one thing we will miss is the logging, the solution you both suggest about a small script is pretty good but I'm just wondering if anyone has found anything with more detail e.g Programs run at what time, that they could suggest? Thanks
Bruce123 Posted December 20, 2009 Posted December 20, 2009 (edited) Another easy way that you can knock up in 5mins is two scripts. Firstly, a logon script... a simple batch file: echo %date%,%time%,logon,%computername%,%username% >> \\servername\sharename\logon.log Then a logoff script that contains: echo %date%,%time%,logoff,%computername%,%username% >> \\servername\sharename\logon.log This should give you the basic details. If you need more detail just add the variable names. If you use this regularly you will probably want something a bit more robust logging to a couple of servers and probably database-based. We use something similar. However, when logging to one log file I found that the size of the logfile would reset to zero intermitently, thereby losing the logs. I did some research and I think that this happens when two processes try to append to the logs file at almost precisely the same time (the first one momemarily locks the file, and then the second tries to append, finds that it is locked/can't access it and creates a new file, thereby deleting the contents of the original log file). So I changed the scripts to log to a seperate file for each user the same as yours >> \\servername\sharename\user\%username%.log This also allows you to see a simple history of where and when someone is logging on/off, and where they are currently logged on for remote desktop support (very handy). I also do the same but creating a seperare logfile per PC, rather than per user, which shows who has logged on and off to any particular PC. I think you can guess how it goes..... the same as yours >> \\servername\sharename\computer\%computername%.log quite simple really Finally, we have another logfile, one master file like you described originally, but I had to convert this to VBScript, which didn't suffer from the same 'bug' of it resetting the logfile to 0 bytes. So we now have 3 log files which are written to at logon/logoff. Thanks, Bruce. Edited December 20, 2009 by Bruce123
gotenks1321 Posted December 20, 2009 Posted December 20, 2009 (edited) One I found on here a while back and have been using at a number of schools Add this VBScript to run on login: 'log Machine Usage Option Explicit Dim strUserDirectory, strCompDirectory, strDate Dim strUser, strComp Dim strUserFile, strCompFile Dim objWshNtwk, objFSO, objTextFile Set objWshNtwk = WScript.CreateObject("WScript.Network") strUserDirectory = "\\servername\logging$\Pupils" strCompDirectory = "\\servername\logging$\Computers" strDate = Now strUser = (objWshNtwk.UserName) strComp = (objWshNtwk.ComputerName) strUserFile = "\" & CStr(strUser) & ".txt" strCompFile = "\" & CStr(strComp) & ".txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForAppending = 8 ' Username Log Set objTextFile = objFSO.OpenTextFile (strUserDirectory &_ strUserFile, ForAppending, True) objTextFile.WriteLine ("User:" & ", " & strUser & ", " _ & "Logged on to Computer" & ", " & strComp & ", " _ & "at" & ", " & strDate) objTextFile.Close 'computer name Log Set objTextFile = objFSO.OpenTextFile _ (strCompDirectory & strCompFile, ForAppending, True) objTextFile.WriteLine ("Computer" & ", " & strComp & ", "_ & "Was logged into by" _ & ", " & strUser & ", " & "at" & "," & strDate) objTextFile.Close WScript.Quit And this VBScript to run at logoff: ' LOGOUT SCRIPT as follows Option Explicit Dim strUserDirectory, strCompDirectory, strDate Dim strUser, strComp Dim strUserFile, strCompFile Dim objWshNtwk, objFSO, objTextFile Set objWshNtwk = WScript.CreateObject("WScript.Network") strUserDirectory = "\\servername\logging$\Pupils" strCompDirectory = "\\servername\logging$\Computers" strDate = Now strUser = (objWshNtwk.UserName) strComp = (objWshNtwk.ComputerName) strUserFile = "\" & CStr(strUser) & ".txt" strCompFile = "\" & CStr(strComp) & ".txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForAppending = 8 ' Username Log Set objTextFile = objFSO.OpenTextFile (strUserDirectory &_ strUserFile, ForAppending, True) objTextFile.WriteLine ("User:" & ", " & strUser & ", " _ & "Logged out of Computer" & ", " & strComp & ", "_ & "at" & ", " & strDate) objTextFile.Close 'computer name Log Set objTextFile = objFSO.OpenTextFile _ (strCompDirectory & strCompFile, ForAppending, True) 'objTextFile.WriteLine (strUser & "," & strComp & "," & strDate) objTextFile.WriteLine ("Computer" & ", " & strComp & ", "_ & "Was logged out of by" _ & ", " & strUser & ", " & "at" & "," & strDate) objTextFile.Close WScript.Quit And finally run this batch as a task each night to tidy up the days records into an archive: @echo off title SPCTracker Archive Script echo. echo This batch script is archiving the days logfiles from SPCTracker. echo. echo. echo Access Physical Server Archive Location echo. E: cd \ cd Logging cd Archive echo. echo Begin Archive Structuring for Day echo. md "%date:/=-%" cd "%date:/=-%" md "Staff" md "Pupils" md "Computers" echo. echo Back up to SPCTracker Root echo. cd .. cd .. echo. echo Start Copying Users Logfiles echo. cd Pupils move *.* "../Archive/%date:/=-%/Pupils/" cd .. cd Staff move *.* "../Archive/%date:/=-%/Staff/" cd .. echo. echo Start Copying Computers Logfiles echo. cd Computers move *.* "../Archive/%date:/=-%/Computers/" cd .. echo. echo Process Complete! echo. pause exit Then you will have a text file created for each user when they login which will be updated everytime they logon and logoff with the computer name. You will also have the same for each computer that is logged onto with the username of the person that has logged into it. You'll have to excuse the description, it's a bit early and my brain isn't working properly yet Edited December 20, 2009 by gotenks1321
mattx Posted December 20, 2009 Posted December 20, 2009 (edited) Make a dir on the local pc called c:\logs [ you can edit this script to do so if you wish ] Compile the script and run it at logon. It will show this in the txt file and will add a new line everytime a user logs on: On 2007-01-24 18:30:30 : User: MattX Logged On To PC: MATTDELL, IP Address: 192.168.1.102 AutoIT script: ; AutoIt Version: 3.10 ; Language: English ; Platform: WinXP ; Author: Matt Marsh ; Script Function: Script that records logon details in log file ; Date: Oct 2005 Dim $sLogPath = "c:\logs\logger.txt" Dim $sLogMsg = "User: " _FileWriteLog($sLogPath, $sLogMsg) Func _FileWriteLog($sLogPath, $sLogMsg) Local $sDateNow Local $sTimeNow Local $sMsg Local $hOpenFile Local $hWriteFile Local $user Local $cname Local $ip $sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC $user = @UserName $cname = @ComputerName $ip = @IPAddress1 $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg & $user & " Logged On To PC: " & $cname & "," & " IP Address: " & $ip $hOpenFile = FileOpen($sLogPath, 1) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWriteLine($hOpenFile, $sMsg) If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc This is the locally held version, I've got another version pointing over to a share - [ so each .txt file is written to a share on a server, I then have a combo box with the list of PCs in an array [ called from an .ini file ] which you can then choose to open up the relevant text file ] - to see the logon history. That is also run from a share so any teacher can use it on the network to check the logon history of a given PC. That code is on my box at work and I'm not back until January now but PM me if you want it and I'll add it to my to do list..... Edited December 20, 2009 by mattx
BJG Posted March 16, 2010 Posted March 16, 2010 ...just been asked to set up something to monitor "how often certain computers are used or last logon", and this was the only relevant thread I could find. I'm not really into hacking around with scripts though - hasn't anyone found a handy bit of software for this kind of thing...?
Bruce123 Posted March 20, 2010 Posted March 20, 2010 You're better off using a script, all it needs to be is one simple line in a text file saved with a .bat extension and added to the domain logon script. Simplez. You could setup the entire thing in 30 minutes. Type this into Notepad: @echo %username% logon %computername% %date% %time% >> \\server\hiddenshare$\%computername%.txt Save this as logon-logon.bat, add it as a domain logon script, create a shared folder on the server for the logs giving it read/write permissions for all users. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now