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
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
this is what i do in the login script
Code: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
This should do the trick!
You can change the location of the userlog.txt file if required.
Code:' 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
Thanks for that, will try that later
You may also like to append logoff events to the text file. The following script will do this.
Code:' 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
There are currently 1 users browsing this thread. (0 members and 1 guests)