• Vielen Dank für den Tipp.

    Allerdings erstellt er mir keinen Ordner für das Logfile. Kann ich ihm das irgendwo beibringen ohne die File.au3 verändern zu müssen?

    Also das er automatisch den Ordner erstellt sofern er nicht vorhanden ist. Im alten Script ging es ja mit Parameter ,9 das er den Ordner erstellt.

    Gut ich könnte ne Abfrage reinmachen aber das möchte ich ungern das muss anders gehen. ^^

    LG

    Schnuecks

  • Ich habe nochmal meine Pingfunktionen überarbeitet.

    Was meint ihr dazu?

    Spoiler anzeigen
    [autoit]

    Func _pingdown($srv)
    Local $Timer = TimerInit()
    Do
    $ping = Ping($srv, 250)
    Until Not $ping or TimerDiff($Timer)>300000

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

    If Not $ping Then
    _FileWriteLog($Log, $txt6 & $srv & $txt7 & @CRLF)
    Else
    _FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
    EndIf

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

    EndFunc ;==>_pingdown

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

    Func _pingup($srv)
    Local $Timer = TimerInit()
    Do
    $ping = Ping($srv, 250)
    Until $ping or TimerDiff($Timer)>300000

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

    If $ping Then
    _FileWriteLog($Log, $txt6 & $srv & $txt8 & @CRLF)
    Else
    _FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
    EndIf

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

    EndFunc ;==>_pingup

    [/autoit]

    Hier nochmal komplett

    Spoiler anzeigen
    [autoit]

    #cs ---------------------------------------------------------------------

    AutoIt Version: 3.2.10.0
    Author: Andreas Heß
    Copyright: Andreas Heß

    Script Function: Reboot mehrerer Server.
    Script Version: 1.9
    Script Date: 02.12.2008

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

    #ce ---------------------------------------------------------------------

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

    #NoTrayIcon
    #include <Date.au3>
    #include <File.au3>

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

    ;------------------------------------------------------------------------
    ;---------------------------- WICHTIGER - HINWEIS------------------------
    ;------------------------------------------------------------------------
    ;------------- Bereich in dem geändert werden darf - Anfang -------------
    ;------------------------------------------------------------------------
    $Domaene = "localdomain.de" ;Domäne
    $Benutzer = "serviceuser" ;ServiceUser
    $Kennwort = "servicepw" ;Kennwort des ServiceUsers
    $Passwort = "manuell" ;Kennwort für manuellen Start
    $timeout = "10" ;Zeit bis zum Neustart in Sekunden

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

    Global $aSrv[20] = ["test01","test02","test03","test04","","","","","","","","","","","","","","","",""]

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

    ;------------------------------------------------------------------------
    ;-------------- Bereich in dem geändert werden darf - Ende --------------
    ;------------------------------------------------------------------------
    ;---------------------------- WICHTIGER - HINWEIS -----------------------
    ;------------------------------------------------------------------------

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

    ;------------------------------------------------------------------------
    ;------------------ Variablen zum Reboot und zum Abbruch ----------------
    ;------------------------------------------------------------------------
    $reboot = @SystemDir & '\shutdown.exe -r -f -d p:1:1 -c "Sonderwartung" -t ' & $timeout & " -m \\"

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

    $cancel = @SystemDir & "\shutdown.exe -a -m \\"
    ;------------------------------------------------------------------------
    ;------------------------- Variablen für Logdatei -----------------------
    ;------------------------------------------------------------------------
    $Log = @ScriptDir & "\logs\Rebootlog vom " & _NowDate() & ".txt"
    If Not FileExists(@ScriptDir & "\logs\") Then DirCreate(@ScriptDir & "\logs\")
    $txt1 = "Automatischer Reboot "
    $txt2 = "Manueller Reboot "
    $txt3 = " wurde ausgelöst "
    $txt4 = " wurde abgebrochen "
    $txt5 = "von " & @UserName
    $txt6 = "Serverstatus "
    $txt7 = " ist OFFLINE "
    $txt8 = " ist ONLINE "
    $txt9 = " ist UNBEKANNT "
    ;------------------------------------------------------------------------
    ;------------------------------- Checkpoint 1 ---------------------------
    ;------------------------------------------------------------------------
    $sec_1 = @UserName
    $manuell = 0
    If $sec_1 = $Benutzer Then
    RunAsSet($Benutzer, $Domaene, $Kennwort)

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

    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _reboot($aSrv[$i])
    Next

    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _pingdown($aSrv[$i])
    Next

    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _pingup($aSrv[$i])
    Next

    RunAsSet()
    Else
    ;------------------------------------------------------------------------
    ;------------------------------- Checkpoint 2 ---------------------------
    ;------------------------------------------------------------------------
    $sec_2 = InputBox("Warnung -- Warnung", "Reboot erfordert Passwort.", "", "*", 250, 50)
    $manuell = 1
    If $sec_2 = $Passwort Then
    RunAsSet($Benutzer, $Domaene, $Kennwort)

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

    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _reboot($aSrv[$i])
    Next

    If MsgBox(4, "Cancel Reboot", "Soll der Reboot abgebrochen werden?", $timeout) = 6 Then
    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _cancel($aSrv[$i])
    Next
    Exit
    EndIf

    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _pingdown($aSrv[$i])
    Next

    For $i = 0 To 19
    If $aSrv[$i] <> "" Then _pingup($aSrv[$i])
    Next

    RunAsSet()
    EndIf
    EndIf

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

    ;------------------------------------------------------------------------
    ;---------------------- Abschnitt Funktionen - Beginn -------------------
    ;------------------------------------------------------------------------
    Func _pingdown($srv)
    Local $Timer = TimerInit()
    Do
    $ping = Ping($srv, 250)
    Until Not $ping or TimerDiff($Timer)>300000

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

    If Not $ping Then
    _FileWriteLog($Log, $txt6 & $srv & $txt7 & @CRLF)
    Else
    _FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
    EndIf

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

    EndFunc ;==>_pingdown

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

    Func _pingup($srv)
    Local $Timer = TimerInit()
    Do
    $ping = Ping($srv, 250)
    Until $ping or TimerDiff($Timer)>300000

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

    If $ping Then
    _FileWriteLog($Log, $txt6 & $srv & $txt8 & @CRLF)
    Else
    _FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
    EndIf

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

    EndFunc ;==>_pingup

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

    Func _reboot($srv)
    If $manuell = 1 Then
    Run($reboot & $srv, "", @SW_HIDE)
    _FileWriteLog($Log, $txt2 & $srv & $txt3 & $txt5 & @CRLF)
    Else
    Run($reboot & $srv, "", @SW_HIDE)
    _FileWriteLog($Log, $txt1 & $srv & $txt3 & $txt5 & @CRLF)
    EndIf
    EndFunc ;==>_reboot

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

    Func _cancel($srv)
    Run($cancel & $srv, "", @SW_HIDE)
    _FileWriteLog($Log, $txt2 & $srv & $txt4 & $txt5 & @CRLF)
    EndFunc ;==>_cancel

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

    ;------------------------------------------------------------------------
    ;----------------------- Abschnitt Funktionen - Ende --------------------
    ;------------------------------------------------------------------------

    [/autoit]


    LG

    Schnuecks