Shutdown Log

  • Weil mich es interessiert, habe ich mir Hilfe von anderen Scripten einen Shutdown-Logger geschrieben.

    Die Log wird in einem Ordner unter Gemeinsame-Dokumente gespeichert, muss wahlweise angepasst werden (da eingeschränkte user und gäste so wenige schreibrechte haben *g*)

    vllt kanns wer gebrauchen

    Spoiler anzeigen
    [autoit]


    #NoTrayIcon

    [/autoit] [autoit][/autoit] [autoit]

    #include <Process.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $CurrentStart = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "ShutdownLog")

    [/autoit] [autoit][/autoit] [autoit]

    If $CurrentStart = '"' & @AutoItExe & '"' Then
    Else
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "ShutdownLog", "REG_SZ", '"' & @AutoItExe & '"')
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists("C:\Dokumente und Einstellungen\All Users\Dokumente\log\") Then
    Else
    DirCreate("C:\Dokumente und Einstellungen\All Users\Dokumente\log\")
    _RunDOS('attrib "C:\Dokumente und Einstellungen\All Users\Dokumente\log" +h /S /D')
    EndIf

    Local $date = @YEAR & "-" & @MON & "-" & @MDAY
    Local $user32 = DllOpen("user32"), $log
    Local $log = "C:\Dokumente und Einstellungen\All Users\Dokumente\log\ShutdownLog_" & @username & ".html"
    opt("OnExitFunc", "Terminate")
    HotKeySet( "^{F9}", "Terminate1")

    [/autoit] [autoit][/autoit] [autoit]

    FileWrite($log,'')
    FileOpen($log, 1)
    Sleep(100)
    FileWrite($log, '<font face=Verdana size=1>')

    FileWrite($log, '<center>[#[ Shutdown Log <b><font color=#00FF00 style=font-size:9px>Start</font></b> ' & @UserName & ' @ ' & @YEAR & '.' & @MON & '.' & @MDAY & ' @ <b><font color=#00FF00 style=font-size:9px>' & @HOUR & ':' & @MIN & ':' & @SEC & '</font></b> ]#] </center><<br>')

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(1)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Terminate()
    DllClose($user32)
    $close = @exitMethod
    If $close = 0 Then
    FileWrite($log, '<center>[#[ Shutdown Log <b><font color=#FF0000 style=font-size:9px>_Natural Shutdown_</font></b> ' & @UserName & ' @ ' & @YEAR & '.' & @MON & '.' & @MDAY & ' @ <b><font color=#FF0000 style=font-size:9px>' & @HOUR & ':' & @MIN & ':' & @SEC & ' </font></b> ]#] </font></center></b><br>')
    ElseIf $close = 1 Then
    FileWrite($log, '<center>[#[ Shutdown Log <b><font color=#FF0000 style=font-size:9px>_Exit Function_</font></b> ' & @UserName & ' @ ' & @YEAR & '.' & @MON & '.' & @MDAY & ' @ <b><font color=#FF0000 style=font-size:9px>' & @HOUR & ':' & @MIN & ':' & @SEC & ' </font></b> ]#] </font></center></b><br>')
    ElseIf $close = 2 Then
    FileWrite($log, '<center>[#[ Shutdown Log <b><font color=#FF0000 style=font-size:9px>_Systray Shutdown_</font></b> ' & @UserName & ' @ ' & @YEAR & '.' & @MON & '.' & @MDAY & ' @ <b><font color=#FF0000 style=font-size:9px>' & @HOUR & ':' & @MIN & ':' & @SEC & ' </font></b> ]#] </font></center></b><br>')
    ElseIf $close = 3 Then
    FileWrite($log, '<center>[#[ Shutdown Log <b><font color=#FF0000 style=font-size:9px>_Logoff_</font></b> ' & @UserName & ' @ ' & @YEAR & '.' & @MON & '.' & @MDAY & ' @ <b><font color=#FF0000 style=font-size:9px>' & @HOUR & ':' & @MIN & ':' & @SEC & ' </font></b> ]#] </font></center></b><br>')
    ElseIf $close = 4 Then
    FileWrite($log, '<center>[#[ Shutdown Log <b><font color=#FF0000 style=font-size:9px>_Shutdown_</font></b> ' & @UserName & ' @ ' & @YEAR & '.' & @MON & '.' & @MDAY & ' @ <b><font color=#FF0000 style=font-size:9px>' & @HOUR & ':' & @MIN & ':' & @SEC & ' </font></b> ]#] </font></center></b><br>')
    EndIf
    FileClose($log)
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func Terminate1()
    Exit (0)
    EndFunc

    [/autoit]