Why use start over call when using batch files?
It appears that I can use either start
or call
to execute batch files however am unsure why you would use one over the other. What are the benefits?
call
runs the given script inside the same interpreter instance, so it can only be used for batch files, but it allows the called script to modify the caller's environment using set
. In Windows NT, call
also allows labels to be called as subroutines; e.g. call :foo
.
On the other hand, start
uses the ShellExecute() function, so it can be used to open practically everything Windows itself can open, including documents, other files, and even Internet URLs. start
also has options to open a separate console window, to use different process priorities, and to run a program without waiting for it to finish. However, if you use start
with a batch file, it will run in a separate interpreter, and any modifications to the environment will not be seen from the caller.
C:\>start /?
Starts a separate window to run a specified program or command.
C:\>call /?
Calls one batch program from another.
Call will not start new window and can be used to call labeled subroutine.