• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Execute a batch file from the command line on Windows

January 9, 2024 by admin Category: How To

You are viewing the article How to Execute a batch file from the command line on Windows  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

This article has been viewed 4,186 times.

This wikiHow teaches you how to execute a batch file (a script file with the .BAT extension) from the Windows command line. You can run the program from the “Run” dialog, or type commands into the terminal window.

Table of Contents

  • Steps
    • Using the Run dialog box
    • Using the Terminal window

Steps

Using the Run dialog box

Image titled Run a Batch File from the Command Line on Windows Step 1

Image titled Run a Batch File from the Command Line on Windows Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/be/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-1.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-1.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ b/be/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-1.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-1.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,”bigHeight”:547,”licensing”:”<div class=”mw-parser-output “></div>”}
Press ⊞ Win + R . The Run dialog box will open.

  • If you want to execute batch file as administrator then see this method.
Image titled Run a Batch File from the Command Line on Windows Step 2

Image titled Run a Batch File from the Command Line on Windows Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/94/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-2.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 9/94/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-2.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-2.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,”bigHeight”:543,”licensing”:”<div class=”mw-parser-output “></div>”}
Click Browse… .
Image titled Run a Batch File from the Command Line on Windows Step 3

Image titled Run a Batch File from the Command Line on Windows Step 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/a0/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-3.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ a/a0/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-3.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-3.jpg”,”smallWidth”:460,”smallHeight”:351,”bigWidth”:728,”bigHeight”:555,”licensing”:”<div class=”mw-parser-output “></div>”}
Navigate to the folder containing the batch file.
Image titled Run a Batch File from the Command Line on Windows Step 4

Image titled Run a Batch File from the Command Line on Windows Step 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/6/6a/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-4.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-4.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 6/6a/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-4.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-4.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:550,”licensing”:”<div class=”mw-parser-output “></div>”}
Click on the batch file to select. The file will be highlighted.
Image titled Run a Batch File from the Command Line on Windows Step 5

Image titled Run a Batch File from the Command Line on Windows Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/b5/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-5.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-5.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ b/b5/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-5.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-5.jpg”,”smallWidth”:460,”smallHeight”:348,”bigWidth”:728,”bigHeight”:550,”licensing”:”<div class=”mw-parser-output “></div>”}
Click Open . The full path to the batch file will be pasted into the Run dialog box.
Image titled Run a Batch File from the Command Line on Windows Step 6

Image titled Run a Batch File from the Command Line on Windows Step 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/7/7c/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-6.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-6.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 7/7c/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-6.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-6.jpg”,”smallWidth”:460,”smallHeight”:347,”bigWidth”:728,”bigHeight”:549,”licensing”:”<div class=”mw-parser-output “></div>”}
Click OK . The batch file will open in a terminal window and execute. When the file is finished running, the bottom of the window will appear a line with the content “Press any key to continue”.
Image titled Run a Batch File from the Command Line on Windows Step 7

READ More:   How to Create a Nitrogen Cycle in an Aquarium

Image titled Run a Batch File from the Command Line on Windows Step 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/17/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-7.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-7.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 1/17/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-7.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-7.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:541,”licensing”:”<div class=”mw-parser-output “></div>”}
Press any key. The terminal window will close after the command executes.

Using the Terminal window

Image titled Run a Batch File from the Command Line on Windows Step 8

Image titled Run a Batch File from the Command Line on Windows Step 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/e0/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-8.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-8.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ e/e0/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-8.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-8.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:542,”licensing”:”<div class=”mw-parser-output “></div>”}
Click menu Windows Start

{“smallUrl”:”https://www.wikihow.com/images_en/0/07/Windowsstart.png”,”bigUrl”:”https://www.wikihow.com/images/thumb/0/07/ Windowsstart.png/30px-Windowsstart.png”,”smallWidth”:460,”smallHeight”:460,”bigWidth”:30,”bigHeight”:30,”licensing”:”<div class=”mw-parser-output “></div>”}

usually located in the lower left corner of the screen.

Image titled Run a Batch File from the Command Line on Windows Step 9

Image titled Run a Batch File from the Command Line on Windows Step 9

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/5b/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-9.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-9.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 5/5b/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-9.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-9.jpg”,”smallWidth”:460,”smallHeight”:341,”bigWidth”:728,”bigHeight”:540,”licensing”:”<div class=”mw-parser-output “></div>”}
Type cmd in the search bar. A list of matches will appear.
Image titled Run a Batch File from the Command Line on Windows Step 10

Image titled Run a Batch File from the Command Line on Windows Step 10

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/99/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-10.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-10.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 9/99/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-10.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-10.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:544,”licensing”:”<div class=”mw-parser-output “></div>”}
Right click on Command Prompt . A menu will appear.
Image titled Run a Batch File from the Command Line on Windows Step 11

Image titled Run a Batch File from the Command Line on Windows Step 11

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/2/22/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-11.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-11.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 2/22/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-11.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-11.jpg”,”smallWidth”:460,”smallHeight”:344,”bigWidth”:728,”bigHeight”:545,”licensing”:”<div class=”mw-parser-output “></div>”}
Click Run as Administrator . A confirmation message will appear.
Image titled Run a Batch File from the Command Line on Windows Step 12

Image titled Run a Batch File from the Command Line on Windows Step 12

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/d/dd/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-12.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-12.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ d/dd/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-12.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-12.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser-output “></div>”}
Click Yes . The command line (administrator) will open.
Image titled Run a Batch File from the Command Line on Windows Step 13

Image titled Run a Batch File from the Command Line on Windows Step 13

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/34/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-13.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-13.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 3/34/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-13.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-13.jpg”,”smallWidth”:460,”smallHeight”:343,”bigWidth”:728,”bigHeight”:543,”licensing”:”<div class=”mw-parser-output “></div>”}
Type cd along with the full path to the directory where the .BAT file is located. Here is an example:

  • If the batch file is on the desktop, type cd UsersYourLoginNameDesktop .
  • If the file is in the downloads folder, enter cd UsersYourLoginNameDownloads .
  • If you don’t know the username, type cd Users and press ↵ Enter to access the Users directory, then type dir and then press ↵ Enter to see the login list.
Image titled Run a Batch File from the Command Line on Windows Step 14

Image titled Run a Batch File from the Command Line on Windows Step 14

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/4d/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-14.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-14.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 4/4d/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-14.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-14.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:541,”licensing”:”<div class=”mw-parser-output “></div>”}
Press ↵ Enter . You will be redirected to the folder containing the batch file.
Image titled Run a Batch File from the Command Line on Windows Step 15

Image titled Run a Batch File from the Command Line on Windows Step 15

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/0/00/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-15.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-15.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 0/00/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-15.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-15.jpg”,”smallWidth”:460,”smallHeight”:346,”bigWidth”:728,”bigHeight”:547,”licensing”:”<div class=”mw-parser-output “></div>”}
Enter the batch file name. For example, if the file is named “program.bat,” you type program.bat .

  • If you don’t know the filename, type the dir command and press ↵ Enter to see the file in the directory. You will find the file you are looking for here.
READ More:   How to Control Excitement
  • Image titled Run a Batch File from the Command Line on Windows Step 16

    Image titled Run a Batch File from the Command Line on Windows Step 16

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/3/35/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-16.jpg/ v4-728px-Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-16.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/ 3/35/Run-a-Batch-File-from-the-Command-Line-on-Windows-Step-16.jpg/v4-728px-Run-a-Batch-File-from-the-Command-Line- on-Windows-Step-16.jpg”,”smallWidth”:460,”smallHeight”:342,”bigWidth”:728,”bigHeight”:541,”licensing”:”<div class=”mw-parser-output “></div>”}
    Press ↵ Enter . The batch file will execute.
  • X

    This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.

    The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.

    This article has been viewed 4,186 times.

    This wikiHow teaches you how to execute a batch file (a script file with the .BAT extension) from the Windows command line. You can run the program from the “Run” dialog, or type commands into the terminal window.

    Thank you for reading this post How to Execute a batch file from the command line on Windows at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « Top 999+ lehenga blouse designs 2019 latest images – Amazing Collection lehenga blouse designs 2019 latest images Full 4K
    Next Post: Top 999+ samantha wedding images – Amazing Collection samantha wedding images Full 4K »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge