1 reply
by valentino
Don't know if you still need help, but...
Every program returns some code. Usually programs return zero on success and >0 on error. To check which code a program returned in batch file you should use "if errorlevel NNN" command.
First of all, there are three ways of starting a program in a batch file:
------------------------------------------------
rem This line starts the program and waits for it to terminate
SomeProgram.exe
rem This line starts the program and also waits for it to terminate
start /wait SomeProgram.exe
rem This line starts the program and DOESN'T wait for it to terminate
start SomeProgram.exe
------------------------------------------------
Now how you can check the return code:
------------------------------------------------
if not errorlevel 1 goto NoError
echo Some error occurred!
goto Finish
:NoError
echo OK, no error!
:Finish
------------------------------------------------
Or this way:
------------------------------------------------
if errorlevel 1 goto GotError
echo OK, no error!
goto Finish
:GotError
echo Some error occurred!
:Finish
------------------------------------------------
This is under WinNT 4.0. There might be some differences under other operating systems.
This discussion is closed to new replies.
Trending Windows Forum posts
Sort by Trending