This wikiHow teaches you how to run a batch file (.BAT) from the Windows command line. You can run the program from the “Run” dialog or by typing commands into a terminal window.

Method 1
Method 1 of 2:

Using Run

  1. 1
    Press Win+R. This opens the Run dialog.
    • If you need to run the batch file as an administrator, see this method instead.
  2. 2
    Click Browse….
    Advertisement
  3. 3
    Navigate to the folder that contains the batch file.
  4. 4
    Click the batch file once to select it. The file is now highlighted.
  5. 5
    Click Open. This pastes the full path to the batch file into the Run box.
  6. 6
    Click OK. The batch file will open in a terminal window and run. When it’s finished running, you’ll see a line at the bottom of the window that says “Press any key to continue.”
  7. 7
    Press any key. This closes the terminal window after the command runs.
  8. Advertisement
Method 2
Method 2 of 2:

Using a Terminal Window

  1. 1
  2. 2
    Type cmd into the search bar. A list of matching results will appear.
  3. 3
    Right-click Command Prompt. A menu will expand.
  4. 4
    Click Run as Administrator. A confirmation message will appear.
  5. 5
    Click Yes. This opens the command line at an elevated (administrator) level.
  6. 6
    Type cd followed by full path to the folder with the .BAT file. Here’s an example:
    • If the batch file is on your desktop, type cd \Users\YourLoginName\Desktop.
    • If it’s in your downloads folder, type cd \Users\YourLoginName\Downloads.
    • If you don’t know what your login name is, type cd \Users and press Enter to go to the Users folder, and then type dir and press Enter to see a list of logins.
  7. 7
    Press Enter. This will move you into the directory.
  8. 8
    Type the name of the batch file. For example, if it’s called “program.bat,” type program.bat.
    • If you don’t know the name, type dir and press Enter to view the files in the folder. You’ll find it there.
  9. 9
    Press Enter. This runs the batch file.
  10. Advertisement

Community Q&A

  • Question
    It gives an error saying "The input line is too long. The syntax of the command is incorrect."
    Community Answer
    Community Answer
    Double-check the code, as there's a command that was not correctly written. Ensure all spaces and special characters are in the proper places.
Advertisement

About This Article

Nicole Levine, MFA
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 263,213 times.
How helpful is this?
Co-authors: 3
Updated: March 8, 2019
Views: 263,213
Categories: Command Prompt
Article SummaryX

1. Press the Windows + R keys.
2. Click Browse.
3. Select the .bat file.
4. Click Open.
5. Click OK.

Did this summary help you?
Advertisement