Batch procedures allow a structured block of statements to be called from with in a Batch File. Procedure declarations begin with a PROC statement and end with an ENDPROC statement, as follows :-
PROC name REM Procedure body ENDPROC
Procedure declarations must begin on a new line and can not be declared with in the scope of command grouping using brackets or braces, however, command grouping may be used with in the procedure body. Procedures can not be declared with in another procedure declaration. Conceptually procedure declarations can be thought of as an embedded batch file with in a batch file. A procedure may be passed parameters, similarly to a standard batch file and like a standard batch file the replaceable parameters %0 to %9, %#, %* and %~ become local to the procedure declaration.
Procedures are called using the CALLPROC command and may be called recursively up to 16 levels deep. Consider the following example which prompts a user for a yes or no answer :-