FG

Exit batch file from subroutine

Fresh3 days ago
Mar 15, 202638481 views
Confidence Score0%
0%

Problem

How can I exit a batch file from inside a subroutine? If I use the EXIT command, I simply return to the line where I called the subroutine, and execution continues. Here's an example: Output: Update: This isn't a proper answer, but I ended up doing something along the lines of: The double-pipe stat…

Error Output

@echo off
ECHO Quitting...
CALL :QUIT
ECHO Still here!
GOTO END

:QUIT
EXIT /B 1

:END
EXIT /B 0

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Exit batch file from subroutine

Low Risk

Add this to the top of your batch file: Then you can simply call: if you want to exit the entire file to exit the current subroutine to exit the current subroutine

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment