Page 1 of 1
Return to original bat file
Posted: 06 May 2017 07:07
by falcios
I run dostest.bat & within that batch file i call dostest2.bat
In the second batch file it has the exit command. What commands do i use to return the second batch file to the 1st to complete.
Thanks in advance.
Re: Return to original bat file
Posted: 06 May 2017 07:20
by aGerman
Batch execution ends if the end of the batch code was reached. Thus, in most cases you don't need to quit it with an additional command. You may use EXIT /B or GOTO :EOF if you want to exit from somewhere whithin your code.
Steffen
Re: Return to original bat file
Posted: 06 May 2017 10:08
by Thor
To be able to return to the 1st batch after finishing the 2nd batch, you need to use the "call" command.
Batch1.bat:
Code: Select all
...
call batch2.bat
rem continue with the rest of batch1 file.
...
Re: Return to original bat file
Posted: 07 May 2017 12:10
by SIMMS7400
Also ensure you use exit /b in your exit protocols of your child script to return to parent process.
Using exit without /b will terminate entire CMD process....
Re: Return to original bat file
Posted: 07 May 2017 15:08
by falcios
Thanks all for the help and codes. Works great.