Very nice script.
Does it deal with machines that are locked, and left on, say,
overnight? Will this capture and deal with that?
On Fri, Mar 21, 2008 at 5:21 AM, Za Vue <[EMAIL PROTECTED]> wrote:
>
>
>
>
> You guys can copy and paste it. Personal stuff has been trimmed; it is part
> of my 9 page logon script. The scripts are identical except for the words
> 'Logon & Logoff' and can be placed inside GPO logoff/logon folders. Of
> course I did not come up with everything myself. When I have time I will
> add the statements to get an IP as well. I map printers, set default
> printers, office shares, personal home folders, force time synch with DC,
> and track logon/logoff.
>
>
>
>
> It has helped me in the past when someone, perhaps even a technician, sworn
> he/she did nothing and "the machine just quick working."
>
> So you logged on at 10:00 & Logged off at 10:25 this morning what did you do
> to the machine?
>
>
>
> -Z.V.
>
>
>
>
>
>
>
>
>
> Option Explicit
>
> On Error Resume Next
>
>
>
> Dim WSHNetwork
>
> Dim WSHShell
>
> Dim WSHSysEnv
>
> Dim GroupDict
>
> Dim oShell, oNet, oFSO, oWshNetwork, oGroupDict, objNet, StrUserName, Prn,
> objUNC
>
> DIM strRemotePath, objFSO, objLogFile, objNetwork, objShell, strText,
> intAns
>
> Dim intConstants, intTimeout, strTitle, intCount, blnLog
>
> Dim strComputerName, strIP, strShare, strLogFile
>
>
>
> StrUserName=objNet.Username
>
> strComputerName = objNetwork.ComputerName
>
>
>
> strShare = "\\servername\log$" 'hidden share, grant proper access to
> domain users
>
> strLogFile = "Logon.log" 'log file name domain users with right
> access to file only
>
> intTimeout = 10 'time out
>
>
>
> Set WSHNetwork = WScript.CreateObject("WScript.Network")
>
> Set WSHShell = WScript.CreateObject("WScript.Shell")
>
> Set WSHSysEnv = WSHShell.Environment("PROCESS")
>
> Set objNet = CreateObject("Wscript.Network")
>
> Set OShell = CreateObject("Shell.Application")
>
> Set oNet = CreateObject("Wscript.Network")
>
> Set Prn = CreateObject("WScript.Network")
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
>
> Set objNetwork = CreateObject("Wscript.Network")
>
> Set objShell = CreateObject("Wscript.Shell")
>
>
>
> '---------------Begin tracking user logoff
> script-------------------------------------------
>
> '' -------------Make three attempts to write to log file.
>
> '' -----------Log date/time, user name, computer name, and IP address.
>
>
>
> If (objFSO.FolderExists(strShare) = True) Then
>
> On Error Resume Next
>
> Set objLogFile = objFSO.OpenTextFile(strShare & "\" _
>
> & strLogFile, 8, True, 0)
>
> If (Err.Number = 0) Then
>
>
>
> intCount = 1
>
> blnLog = False
>
> Do Until intCount = 3
>
> objLogFile.WriteLine "Logoff ; " & Now & " ; " _
>
> & strComputerName & " ; " & strUserName & " ; " & strIP
>
> If (Err.Number = 0) Then
>
> intCount = 3
>
> blnLog = True
>
> Else
>
> Err.Clear
>
> intCount = intCount + 1
>
> If (Wscript.Version > 5) Then
>
> Wscript.Sleep 200
>
> End If
>
> End If
>
> Loop
>
> On Error GoTo 0
>
> If (blnLog = False) Then
>
> strTitle = "Logon Error"
>
> strText = "Log cannot be written."
>
> strText = strText & vbCrlf _
>
> & "Another process may have log file open."
>
> intConstants = vbOKOnly + vbExclamation
>
> intAns = objShell.Popup(strText, intTimeout, strTitle, _
>
> intConstants)
>
> End If
>
> objLogFile.Close
>
> Else
>
> On Error GoTo 0
>
> strTitle = "Logon Error"
>
> strText = "Log cannot be written."
>
> strText = strText & vbCrLf & "User may not have permissions,"
>
> strText = strText & vbCrLf & "or log folder may not be shared."
>
> intConstants = vbOKOnly + vbExclamation
>
> intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants)
>
> End If
>
> Set objLogFile = Nothing
>
> End If
>
>
>
> ' Clean up and exit.
>
> Set objFSO = Nothing
>
> Set objNetwork = Nothing
>
> Set objShell = Nothing
>
>
>
> Wscript.Quit
>
>
>
>
>
>
~ Upgrade to Next Generation Antispam/Antivirus with Ninja! ~
~ <http://www.sunbelt-software.com/SunbeltMessagingNinja.cfm> ~