Sign in to follow this  
Followers 0
Likurg

How to retrieve exit code and output of another programm

4 posts in this topic

#1 ·  Posted (edited)

Hello.

I have an AutoIt script.

It calls another process and I need to things:

1) Retrieve output of that another process

2) Retrieve exit code of another process

Currently, the code gets only output(from out and err):

Local $cmd = $BuildExePath & " /nologo /t:rebuild /p:Configuration=" & $ConfigName & " "  & $SolutionName
    LogData("Cmd: " & $cmd)
    Local $process = Run(@ComSpec & ' /c ' & $cmd, $CurrentProjectDir, @SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD)
    Local $line
    While 1
        $line &= StderrRead($process)
        If @error Then ExitLoop
        Sleep(10)
    WEnd
    While 1
        $line &= StdoutRead($process)
        If @error Then ExitLoop
        Sleep(10)
    WEnd

But I can not get exit code of msbuild

I tried to use ProcessWaitClose and check @extended, but it seems, that it doesn't work this way,

because @extended was something like -8983429347, but msbuild.exe must return 0 if everything is ok.

I tried to use ShallExecute and RunWait, these two functions return exit code, but

I don't see any possibility to retrieve output with them.

Please, help!

Any help would be highly appreciated.

Edited by Likurg

Share this post


Link to post
Share on other sites



It's a kernel32.dll call to GetExitCodeProcess. A demo script was posted a while back by a certain rakishly good-looking bird.

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

A demo script was posted a while back by a certain rakishly good-looking bird.

post-3602-12666179264753_thumb.jpeg

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0