timbo343 Posted March 7, 2007 Posted March 7, 2007 for users logged onto a computer in a certain room. Im sure it has been done before but can someone point me in the right direction please T
browolf Posted March 7, 2007 Posted March 7, 2007 this is what i do in the login script for /f "tokens=1,2,3* delims=/ " %%a in ('date /t') do set date=%%b%%c%%d for /f "tokens=1,2 delims=:" %%a in ('time /t') do set time=%%a%%b echo %date%,%time%,%username% >> \\backup\logs$\computer\%computername%.txt echo %date%,%time%,%computername% >> \\backup\logs$\user\%username%.txt
djm968 Posted March 7, 2007 Posted March 7, 2007 This should do the trick! You can change the location of the userlog.txt file if required. ' Author: Darren Mussenden ' Purpose: logs user logons to the specified text file ' ___________________________________________________________________ ' Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set objNetwork = CreateObject("Wscript.Network") Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") 'alter the path to the text file as needed for your environment Set f = fso.OpenTextFile("C:\userlog.txt", ForAppending, True) strComputer = objNetwork.ComputerName strUser = objNetwork.UserDomain & Chr(92) & objNetwork.UserName 'alter the text strings as you like f.Write "User " & strUser & " logged on to computer " & strComputer & " at " & Now & vbCrLf & vbcrlf f.Close
djm968 Posted March 7, 2007 Posted March 7, 2007 You may also like to append logoff events to the text file. The following script will do this. ' Author: Darren Mussenden ' Purpose: logs user logoffs to the specified text file Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set objNetwork = CreateObject("Wscript.Network") Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") 'alter the path to the text file as needed for your environment Set f = fso.OpenTextFile("c:\userlog.txt", ForAppending, True) strComputer = objNetwork.ComputerName strUser = objNetwork.UserDomain & Chr(92) & objNetwork.UserName 'alter the text strings as you like f.Write "User " & strUser & " logged off of computer " & strComputer & " at " & Now & vbCrLf & vbcrlf f.Close
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