Collections:
Other Resources:
"call command" vs. "command"
What is the difference between "call command" and "command" in a batch file?
✍: FYIcenter.com
There are two formats to run another batch file (or any command) in a batch file:
1. "command" - Run the batch file (or any command) directly. The given command will be invoked in the current batch execution context.
2. "call command" - Run the batch file (or any command) indirectly with the "call" batch command. The given command will be invoked in a child batch execution context.
If the given command is a built-in command or an executable program, the above two formats behave almost in the way.
But if the given command is another batch file, "call command" behaves very different than "command".
When running another batch file in the current batch execution context using the "command" format, the current batch execution context will be terminated when the other batch file reaches the end.
When running another batch file in a child batch execution context using the "call command" format, the child batch execution context will be terminated when the other batch file reaches the end. The current batch execution context will stay to continue on the next line.
Here is batch file, Call-Batch.bat, that running another batch file in two formats, "call command" and "command":
@echo off rem Call-Batch.bat - Call other batch files call Other-Batch.bat "First call" call Other-Batch.bat "Second call" Other-Batch.bat "Third call" Other-Batch.bat "Fourth call"
There is the other batch file, Other-Batch.bat, to be called to perform some tasks:
@echo off rem Other-Batch.bat - The other batch file to be called echo %1 - Running the other batch
Here the execution result of Call-Batch.bat:
C:\fyicenter>Call-Batch.bat "First call" - Running the other batch "Second call" - Running the other batch "Third call" - Running the other batch
Why the "Fourth call" was not executed? Because the Call-Batch.bat execution context was terminated by running "Other-Batch.bat" directly in the context.
⇒ "if" - Run Command Conditionally
2021-04-02, 1887🔥, 0💬
Popular Posts:
What is the startup program "QuickSet MFC Application - quickset.exe" on my Windows 8 computer? Can ...
How to restore Bluetooth icon in the taskbar (system tray) on Windows 7? I removed it by a mistake. ...
How to install PHP engine on Windows systems? If you followed our Downloading PHP Engine tutorial , ...
How to remove WZQKPICK.exe from the startup application list to gain performance and reduce security...
What is helpctr.exe - Microsoft Help and Support Center? helpctr.exe is the executable binary file o...