Fehlerrückgabe von Dos-Prog

  • Hallo Zusammen

    Hab noch ne frage, bekomms einfach nicht gebacken. Ich möchte in Autoit v3 ein Dos-Programm starten, z.B.

    _RunDOS ("net time \\server /set /yes")
    oder mit
    Run("net time \\server /set /yes")

    geht ja, nur würde ich gerne eine meldung bekommen, wenn des Dos-Prog einen Fehler bringt, ähnlich wie in einer Bat-Datei mit,

    net time \\server /set /yes
    if not errorlevel 2 goto ...........
    .........
    msg * test ok

    Ich komm einfach nicht dahinter, wie man sowas anstellt. Meine Frage soll sich jetzt nicht unbedingt auf den "net" Befehl festlegen, denke das geht irgendwie mit fast jeden Programm. Hoffe es hat jemand einen Tipp für mich.

    Grüsse
    Karl

  • Du könntest die @error Variable abfragen. Inder Online Hilfe fand ich dies:

    ...

    Return Value
    Success: The PID of the process that was launched.
    Failure: Depends on RunErrorsFatal; see Remarks.

    Remarks
    To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)
    After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait function instead.
    By default the script will terminate with a fatal error if the Run function fails. To set @error 1, @extended to GetLastError() Windows API and return 0 as an indication of failure
    ...

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

  • hallo alex

    danke für deine antwort, hab leider autoit noch nicht so ganz kappiert, in der hilfe hab ichs auch schon gefunden, aber wie gesagt, ich kappiers noch nicht. Weist du eventuell noch irgend welche Beispiele im Netz, wo sowas behandelt wird?

    grüsse
    Karl

  • Probiere es mal so ...

    [autoit]


    $exitCode = RunWait(@SystemDir & '\net.exe time \\server /set /yes')
    ; 0 = OK (logisch); ungleich 0 = nicht OK (auch logisch)
    MsgBox(266304, '...', 'Der Returncode ist: ' & $exitCode)

    [/autoit]


    Gruß
    Greenhorn


  • Hi Greenhorn

    funktioniert und habs jetzt sogar kappiert. Schon wieder was gelert :)

    Danke noch mal allen
    Gruss
    Karl