Called file with exit /b exits main file batch

I have two files:

File1.bat:

@echo of
File2.bat
pause

File2.bat:

@echo off
echo hello
exit /b

I expect File1.bat to call File2.bat and then pause, however the exit /b command is exiting the console like a plain exit command. Why is this?

2

1 Answer

One problem is that you didn't use call when calling the second file, so it wouldn't return no matter what it does.

Try

@echo of
call File2.bat
pause
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like