start - Execute Other Batch Files Asynchronously

Maintained on

It is common to use batch files to call multiple batch files created separately from a batch file for scheduled execution. It is also common to execute specific exe files from batch files.

This page provides an easy-to-understand explanation of the start command, which is used to execute other programs or batch files from a batch file, from basic usage to setting options.

Basic usage of the start command

The basic usage of the start command is as follows:

start [title] [path to program to be executed] [parameters to be passed to the program]

To be more specific, the command can be expressed as follows, but in most cases, only the title of the program to be executed, the path to the program, and the parameters to be passed to the program are specified as shown above.

start [title] [/d <path to program to be executed>] [/i] [{/min | /max}] [{/separate | /shared}] [{/low | /normal | /high | /realtime | /abovenormal | /belownormal}] [/node <NUMA node>] [/affinity <HEX>] [/wait] [/b] [/machine <x86|amd64|arm|arm64>] [additional command/program] [parameters to be passed to the program]

The start command executes the specified program at the specified path, but it does not wait for the program to complete before moving on to the next process.

Examples of the start command

Executing other batch files

As an example, prepare the caller.cmd file to be executed directly and the callee.cmd file to be called.

The caller.cmd file is as follows:

caller.cmd
@echo off

echo Started caller.cmd.

start callee.cmd

echo Finished caller.cmd.

Similarly, callee.cmd looks like this:

callee.cmd
@echo off

echo Started callee.cmd.

rem Wait for 5 seconds
timeout /t 5 /nobreak >nul

echo Finished callee.cmd.

After configuring as above, executing caller.cmd will display another command prompt window and execute each batch file as follows:

×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2024 Ribbit App Development All rights reserved.
 
C:\users\user>caller.cmd
Started caller.cmd.
Finished caller.cmd.
C:\users\user>
×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2024 Ribbit App Development All rights reserved.
 
C:\users\user>
Started callee.cmd.
Finished callee.cmd.

When these are executed in order, the result is as follows:

Started caller.cmd.
Started callee.cmd.
Finished caller.cmd.
Finished callee.cmd.

callee.cmd finishes after caller.cmd finishes.

caller.cmd finishes instantly, but callee.cmd waits for 5 seconds using the timeout command.

Using the start command allows the next process to be executed without waiting for the called batch file to complete.

Executing a batch file with arguments

Next, we will explain how to execute a batch file with arguments.

Prepare the caller.cmd file to be executed directly and the callee.cmd file to be called.

caller.cmd
@echo off

echo Started caller.cmd.

start callee.cmd 1

start callee.cmd 2

echo Finished caller.cmd.
callee.cmd
@echo off

echo Started callee.cmd.

echo This is the %1st execution.

rem Wait for 5 seconds
timeout /t 5 /nobreak >nul

echo Finished callee.cmd.

After configuring as above, executing caller.cmd will display two new windows and execute each batch file.

The result will be as follows:

×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2024 Ribbit App Development All rights reserved.
 
C:\users\user>
This is the first execution.
callee.cmd has finished.
Started callee.cmd.
×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2024 Ribbit App Development All rights reserved.
 
C:\users\user>
This is the second execution.
callee.cmd has finished.
caller.cmd has finished.

Waiting for the called program to finish

If you want to wait for the called batch file to finish before proceeding to the next process, use the /wait option of the start command.

By using the /wait option, the next process will not be executed until the called program has finished.

Alternatively, you can use the call command to wait for the called program to finish before proceeding to the next process.

For more information on the call command, see the following page:

Quiz

Practice Problem

When calling a batch file from another batch file, which command allows the next process to be executed without waiting for the called batch file to complete?

sub.cmd
@echo off

echo Started sub.cmd.

rem Wait for 5 seconds
timeout /t 5 /nobreak >nul

echo Finished sub.cmd.
回答がサーバーに送信されることはありません
#Command Prompt #Batch File #Arguments #Command Line #Command