How to Run a Batch File from the Command Line on Windows

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. Press . This opens the Run dialog.
Method 1 of 2:

Using Run

  1. How to Run a Batch File from the Command Line on Windows Picture 1How to Run a Batch File from the Command Line on Windows Picture 1
    Press Win+R. This opens the Run dialog.
    1. If you need to run the batch file as an administrator, see this method instead.
  2. How to Run a Batch File from the Command Line on Windows Picture 2How to Run a Batch File from the Command Line on Windows Picture 2
    Click Browse….
  3. How to Run a Batch File from the Command Line on Windows Picture 3How to Run a Batch File from the Command Line on Windows Picture 3
    Navigate to the folder that contains the batch file.
  4. How to Run a Batch File from the Command Line on Windows Picture 4How to Run a Batch File from the Command Line on Windows Picture 4
    Click the batch file once to select it. The file is now highlighted.
  5. How to Run a Batch File from the Command Line on Windows Picture 5How to Run a Batch File from the Command Line on Windows Picture 5
    Click Open. This pastes the full path to the batch file into the Run box.
  6. How to Run a Batch File from the Command Line on Windows Picture 6How to Run a Batch File from the Command Line on Windows Picture 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. How to Run a Batch File from the Command Line on Windows Picture 7How to Run a Batch File from the Command Line on Windows Picture 7
    Press any key. This closes the terminal window after the command runs.
Method 2 of 2:

Using a Terminal Window

  1. How to Run a Batch File from the Command Line on Windows Picture 8How to Run a Batch File from the Command Line on Windows Picture 8
    Click the
    How to Run a Batch File from the Command Line on Windows Picture 9How to Run a Batch File from the Command Line on Windows Picture 9
    menu. It's usually at the bottom-left corner of the screen.
  2. How to Run a Batch File from the Command Line on Windows Picture 10How to Run a Batch File from the Command Line on Windows Picture 10
    Type cmd into the search bar. A list of matching results will appear.
  3. How to Run a Batch File from the Command Line on Windows Picture 11How to Run a Batch File from the Command Line on Windows Picture 11
    Right-click Command Prompt. A menu will expand.
  4. How to Run a Batch File from the Command Line on Windows Picture 12How to Run a Batch File from the Command Line on Windows Picture 12
    Click Run as Administrator. A confirmation message will appear.
  5. How to Run a Batch File from the Command Line on Windows Picture 13How to Run a Batch File from the Command Line on Windows Picture 13
    Click Yes. This opens the command line at an elevated (administrator) level.
  6. How to Run a Batch File from the Command Line on Windows Picture 14How to Run a Batch File from the Command Line on Windows Picture 14
    Type cd followed by full path to the folder with the .BAT file. Here's an example:
    1. If the batch file is on your desktop, type cd UsersYourLoginNameDesktop.
    2. If it's in your downloads folder, type cd UsersYourLoginNameDownloads.
    3. 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. How to Run a Batch File from the Command Line on Windows Picture 15How to Run a Batch File from the Command Line on Windows Picture 15
    Press Enter. This will move you into the directory.
  8. How to Run a Batch File from the Command Line on Windows Picture 16How to Run a Batch File from the Command Line on Windows Picture 16
    Type the name of the batch file. For example, if it's called 'program.bat,' type program.bat.
    1. 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. How to Run a Batch File from the Command Line on Windows Picture 17How to Run a Batch File from the Command Line on Windows Picture 17
    Press Enter. This runs the batch file.
5 ★ | 1 Vote