0 0 Votes

Continue calling Batch Script after EXIT

Question by Guest | 05/05/2016 at 08:05

I am using the EXIT command in a Windows Batch Script (.BAT) in order to abort the script under certain circumstances.

Taken by itself this is working quite well. However, my script is called by another superior superordinate script and as soon as the EXIT command has been executed, also the calling script stops and not only the current one.

What can I do to only cancel the subordinate script and to keep the calling script file running?

ReplyPositiveNegative

Stefan Trost

Show Profile | Message
Avatar
0Best Answer
0 Votes

With the command EXIT you finish the complete CMD.EXE and not only the execution of the current batch file.

For only canceling the current batch file or the subroutine, you can just pass the parameter /B and write "EXIT /B" instead of "EXIT" only:

EXIT /B

By the way, you can also optionally pass an error code behind /B which is then reported to the superior calling script. For example, you can write "EXIT /B 10" for passing the error code "10".
05/05/2016 at 16:11

ReplyPositive Negative
Reply

Related Topics

How to edit a Batch Script
Question | 1 Answer
What is a Batch Script?
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.