netzwerk shutdown script kürzen

  • Spoiler anzeigen
    [autoit]

    $ip_1 = "172.16.1.92"
    $ip_2 = "172.16.1.93"
    $ip_3 = "172.16.1.94"

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

    $anfang = "shutdown.exe -s -m \\"
    $ende = " -t 30 -c ""Shutdown"" -f"
    $own_ip = @IPAddress1

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

    $file = FileOpen(@DesktopDir & "\aha.cmd",2)

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

    if $ip_1 = $own_ip Then
    $am_emde = $anfang & @IPAddress1 & $ende
    Else
    FileWrite($file,$anfang & $ip_1 & $ende & @CRLF)
    EndIf

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

    if $ip_2 = $own_ip Then
    $am_emde = $anfang & @IPAddress1 & $ende
    Else
    FileWrite($file,$anfang & $ip_2 & $ende & @CRLF)
    EndIf

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

    if $ip_3 = $own_ip Then
    $am_emde = $anfang & @IPAddress1 & $ende
    Else
    FileWrite($file,$anfang & $ip_3 & $ende & @CRLF)
    EndIf

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

    FileWrite($file,$am_emde)
    FileClose($file)
    ShellExecute(@DesktopDir & "\aha.cmd")

    [/autoit]

    so nun zu meiner frage.
    wie kann ich dieses script kürzen - vll mit einer schleife - da es im netzwerk viele computer sind und ich nicht für jeden pc eine if abfrage kopieren will.

    ich möchte dass der pc, welcher dieses script gestartet hat, als leztes heruntergefahren wird. deshalb die ganzen abfragen

    Einmal editiert, zuletzt von fabulous (12. März 2009 um 17:04)

  • Ungetestet, mangels Netzwerk und shutdown.exe :D

    Spoiler anzeigen
    [autoit]

    Dim $ip[3]= ["172.16.1.92","172.16.1.93","172.16.1.94"]

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

    For $i = 0 To UBound($ip)-1
    If $ip[$i] <> @IPAddress1 Then
    RunWait(@ComSpec & " /c " & "shutdown.exe -s -m \\" & $ip[$i] & ' -t 30 -c "Shutdown" -f',"",@SW_HIDE)
    EndIf
    Next

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

    Sleep(30000)
    Shutdown(1)

    [/autoit]