Return to original bat file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
falcios
Posts: 43
Joined: 02 Mar 2017 05:38

Return to original bat file

#1 Post by falcios » 06 May 2017 07:07

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.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Return to original bat file

#2 Post by aGerman » 06 May 2017 07:20

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

Thor
Posts: 43
Joined: 31 Mar 2016 15:02

Re: Return to original bat file

#3 Post by Thor » 06 May 2017 10:08

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.
...

SIMMS7400
Posts: 541
Joined: 07 Jan 2016 07:47

Re: Return to original bat file

#4 Post by SIMMS7400 » 07 May 2017 12:10

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....

falcios
Posts: 43
Joined: 02 Mar 2017 05:38

Re: Return to original bat file

#5 Post by falcios » 07 May 2017 15:08

Thanks all for the help and codes. Works great.

Post Reply