Archive: How to get an errorlevel ...


How to get an errorlevel ...
Hi All,

i want to start a batch-file using execwait and want to have
the errorlevel back.

So i tried :

ExecWait '"$TEMP\test.bat $0"'

but i didn't get any exit code back :mad:
What is wrong?


Thanks Jens


The parameters shouldn't be quoted together. Use ExecWait $TEMP\test.bat $0


See that code - where is my fault ...
Thanks for your help !!


I didn't get the return code ...


Don't quote the parameters together...
ExecWait '"$TEMP\alive" /Repeat=3 /Timeout=3 11.2.20.4' $R0

And plase attache large scripts. I have attached your script to this message.


have the bat create a file that can be read by nsis:


@echo off
cd %TEMP%
if exist errlvl.ini attrib -S -H -R
echo [errorlevel]>errlvl.ini
alive /Repeat=3 /Timeout=3 11.2.20.4 %1

if errorlevel 255 echo value=255>>errlvl.ini
if errorlevel 8 echo value=8>>errlvl.ini
if errorlevel 7 echo value=7>>errlvl.ini
if errorlevel 6 echo value=6>>errlvl.ini
if errorlevel 5 echo value=5>>errlvl.ini
if errorlevel 4 echo value=4>>errlvl.ini
if errorlevel 3 echo value=3>>errlvl.ini
if errorlevel 2 echo value=2>>errlvl.ini
if errorlevel 1 echo value=1>>errlvl.ini
if errorlevel 0 echo value=0>>errlvl.ini
cls
Then ExecWait the bat file like so:

Function alive
ExecWait "$TEMP\runh.exe $TEMP\test2.bat $R0"
ReadINIStr $2 $TEMP\errlvl.ini errorlevel value
; done:
MessageBox MB_YESNO|MB_ICONQUESTION "Errorlevel : $R0" IDYES
FunctionEnd

You don't need no batch file for it...

ExecWait command [user_var(exit code)]

Execute the specfied program and wait for the executed process to quit. See Exec for more information. If no output variable is specified ExecWait sets the error flag if the program executed returns a nonzero error code, or if there is an error. If an output variable is specified, ExecWait sets the variable with the exit code (and only sets the error flag if an error occurs; if an error occurs the contents of the user variable are undefined). Note, if the command could have spaces, you may with to put it in quotes to delimit it from parameters. i.e.: ExecWait '"$INSTDIR\command.exe" parameters'