start und shutdown klappt nicht

  • also,
    erstmal guten abend.

    ich habe seit ner stunde versucht und versucht.. nix klappt.

    ich bin anfänger, und kenn mich nich so gut aus.
    doch das is mein code, der in den autostart soll.
    folgendes sol er ausführen:
    spiel starten, warten bis es beendet wird, und dann den pc runterfahren.
    die .exe heist "CNC3EP1.exe"

    Code
    run ( "P:\Program Files\Electronic Arts\Command & Conquer 3 Kanes Rache\cnc3ep1.exe" )
    
    
    ProcessWait ( "cnc3ep1.exe" )
    
    
    ProcessWaitClose ( "cnc3ep1.exe")
    
    
    Shutdown ( 1 )

    ich verzweifel langsam......
    wäre echt froh für hilfe

  • Hi,

    keine Ahnung ob das schon unter Bots fällt, aber ich denke mal das geht noch in Ordnung ...

    Das Stichwort ist "defensive Programmierung. ;)

    Spoiler anzeigen
    [autoit]

    #include <Constants.au3>

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

    Global $sFilePath = "P:\Program Files\Electronic Arts\Command & Conquer 3 Kanes Rache\cnc3ep1.exe"
    Global $sFile = "cnc3ep1.exe"

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

    If (FileExists ($sFilePath)) Then

    If (Run ( $sFilePath )) Then

    If (ProcessWait ( $sFilePath )) Then

    If (ProcessWaitClose ( $sFilePath )) Then

    Shutdown ( 1 )
    EndIf
    Else
    ErrorMsg ("Prozess existiert nicht!")
    EndIf
    Else
    ErrorMsg ("Datei konnte nicht gestartet werden!")
    EndIf
    Else
    ErrorMsg ("Datei existiert nicht!")
    EndIf

    Func ErrorMsg ($text)

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

    Return MsgBox (BitOR($MB_OK, $MB_ICONHAND), Default, StringFormat ($text, 0), 0, 0)
    EndFunc

    [/autoit]

    Gruß
    Greenhorn