Jump to content

Recommended Posts

Posted
Is there such a piece of software which can tell me how often a machine on a network is logged into over a period of time? I know things like impero do it but I just want a stand alone solution which will tell me if my staff are using the stations we spend thousands on because the old ones were "too slow to use".
Posted

There are a number of logon tracker ideas on here. I use a vbscript that runs a logon and logoff, all it does is write the username, computer name, ip, mac, date and time to log file.

 

It’s crude, but gets me the basic info of who logged on last to a machine.

 

Here is the EDU logon tracker

EduGeek Logon Tracker

 

Here is an old thread that might help.

 

http://www.edugeek.net/forums/scripts/4882-script-track-user-logins.html

Posted

These two lines in a batch file does the job for me, logs computer usage and keeps an individual user log:-

 

echo LOGIN %date%, %time%, %computername%, %username%, >> \\server\Logs\PCs\%computername%.csv

echo LOGIN %date%, %time%, %computername%, %username%, >> \\server\Logs\Users\%username%.csv

 

Andrew

Posted

or even a version that asks users why they are on a pc

 

Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
Dim Message, result
Dim Title, Text1, Text2, mydatestring, mytimestring, WshNetwork, wshShell, strComputerName


Set WshNetwork = WScript.CreateObject("WScript.Network")
Set wshShell = WScript.CreateObject( "WScript.Shell" )

myDateString = Date()
mytimestring = Time()
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )

strDirectory = "\\servee\share$\folder"
strFile = "\netbook usage.csv"
'strText = ""

' Define dialog box variables.
Message = "Why are you using this PC/Laptop"           
Title = "PC Usage Survey"
Text1 = "User input canceled"
Text2 = "You entered:" & vbCrLf

' Ready to use the InputBox function ' InputBox(prompt, title, default, xpos, ypos) ' prompt:    The text shown in the dialog box
' title:     The title of the dialog box ' default:   Default value shown in the text box ' xpos/ypos: Upper left position of the dialog box 
' If a parameter is omitted, VBScript uses a default value.

result = InputBox(Message, Title, "", 100, 100)

' Evaluate the user input.
'If result = "" Then    ' Canceled by the user
'    WScript.Echo Text1
'Else 
'    WScript.Echo Text2 & result
'End If

'writeout bits
'
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFolder = objFSO.CreateFolder(strDirectory)
  WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
  Wscript.Echo "Just created " & strDirectory & strFile
End If 

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes result every time you run this VBScript
objTextFile.WriteLine("Pcname," & strComputerName & "," & "Username," & WshNetwork.UserName &"," &"Date," & myDateString &"," & "Time," & myTimeString & "," & "Reason," & Result)
objTextFile.Close


Posted

been having a look at this again and trying to code something that recorded the time difference between logon-off as well as actual time stamps when i found this on my pendrive (no idea if i wrote it / modified it / pinched it from somewhere) but this seems to do a decent job records to a csv on username, {date, time}logon,{date, time}logoff,minutes difference,pc name

 

option explicit  
'On Error Resume Next

dim loggedtime, strComputer, objWMIService, colItems, objItem, logon, logoff, strComputerName, wshShell, WshNetwork 
dim strDirectory, strFile, objFSO, objFile, objfolder, objTextFile

Set wshShell = WScript.CreateObject( "WScript.Shell" )
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

strComputer = "."
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
strDirectory = "\\server\share$\test scripts\"
strFile = "userlog.csv"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Caption='explorer.exe'", "WQL", _
   wbemFlagReturnImmediately + wbemFlagForwardOnly)
dim creationDate

For Each objItem In colItems
   creationDate = WMIDateStringToDate(objItem.CreationDate)
Next

loggedtime = DateDiff("n", creationDate, Now)
logon = left(creationdate, 10) & "," & right(creationdate, 8)
logoff = left(now, 10) & "," & right(now, 8)
'wscript.echo WshNetwork.UserName & "," & logon & "," & logoff & "," & loggedtime & "," & strComputerName

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFolder = objFSO.CreateFolder(strDirectory)
  WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
  'Wscript.Echo "Just created " & strDirectory & strFile
End If 

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes result every time you run this VBScript
objTextFile.WriteLine(WshNetwork.UserName & "," & logon & "," & logoff & "," & loggedtime & "," & strComputerName)
objTextFile.Close


Function WMIDateStringToDate(dtmDate)

WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...