\\ Amazon パソコン・周辺機器 クーポンをチェックしよう!! //

How to Execute .exe Files in a Batch File: A Comprehensive Guide to Start and Call Commands

How to Start and Call Commands Image

Do you know how to execute .exe files in a batch file using the start and call commands? Although these two commands seem similar, there are significant differences in their execution timing and behavior. In this article, we’ll explain how to use these commands and what sets them apart.

目次

Commands to Execute .exe Files

In a batch file, .exe files can be executed using two primary commands:

  • Start Command
  • Call Command

Each of these commands has distinct characteristics, so you need to choose the appropriate one depending on your purpose.

How to Use the Start Command

The start command opens a new command prompt window to execute the specified program.

Basic syntax:

start "" "path to the program"

Key points:

  • The first pair of "" specifies the window title, but leaving it empty is fine.
  • When specifying a full path, enclose it in double quotes.

Example:

start "" "C:\Program Files\Microsoft Office\root\Office16\excel.exe"
start "" "C:\Program Files\Microsoft Office\root\Office16\winword.exe"

Official documentation:

How to Use the Call Command

The call command is used to call another batch file or program within the current batch file.

Basic syntax:

call "path to the program"

Key points:

  • The next command will not execute until the program called by call finishes.
  • Some built-in Windows programs (e.g., notepad.exe) can be executed without specifying the full path.

Example:

call "C:\Program Files\Microsoft Office\root\Office16\excel.exe"
call "C:\Program Files\Microsoft Office\root\Office16\winword.exe"

Official documentation:

Differences Between Start and Call

FeatureStart CommandCall Command
Execution timingAsynchronous (next command runs immediately)Synchronous (next command waits until the current one finishes)
Simultaneous executionPossibleNot possible (runs commands one at a time)
Error handlingProceeds even if an error occurs in the current commandStops execution on error
Main use caseFor launching multiple programs simultaneouslyFor ensuring sequential execution

Example Batch File Creations

1. Creating start.bat

start.batの内容

File content:

start "" "C:\Program Files\Microsoft Office\root\Office16\excel.exe"
start "" "C:\Program Files\Microsoft Office\root\Office16\winword.exe"

Result:

  • Both Excel and Word will launch at the same time.

2. Creating call.bat

call.batファイルの内容

File content:

call "C:\Program Files\Microsoft Office\root\Office16\excel.exe"
call "C:\Program Files\Microsoft Office\root\Office16\winword.exe"

Result:

  • Excel will launch, and Word will only open after Excel is closed.

Frequently Asked Questions (FAQ)

Q1: Can I run a program invisibly using the start command?

A1: Yes, by adding the /B option, you can run a program without opening a new window.

start /B "" "path to the program"

Q2: Is it possible to run multiple programs simultaneously with the call command?

A2: No, the call command executes programs one at a time. For simultaneous execution, use the start command.

Q3: How do I handle spaces in file paths?

A3: Enclose the entire file path in double quotes.

start "" "C:\Program Files\Example\program.exe"

Q4: Are there other ways to execute .exe files besides start and call?

A4: You can directly specify the .exe file in the batch script, but for better control and error handling, using start or call is recommended.

Conclusion

When executing .exe files in a batch file, you should choose between the start and call commands based on your needs:

  • For running multiple programs simultaneously: Use the start command.
  • For ensuring sequential execution: Use the call command.

Both commands are valuable tools for automating processes in Windows, and understanding their differences will help you create more efficient batch files.

Tamaglo

Thank you for reading!

Comments

To comment

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here

目次