How to Execute batch file from command line on Windows

Today's TipsMake will show you how to execute batch files (script files with .BAT extension) from the Windows command line. You can run the program from the 'Run' dialog box, or type the command into a terminal window.

Use the Run dialog box

How to Execute batch file from command line on Windows Picture 1How to Execute batch file from command line on Windows Picture 1

Press ⊞ Win+R . The Run dialog box opens.

If you want to execute the batch file as administrator then check out this method.

How to Execute batch file from command line on Windows Picture 2How to Execute batch file from command line on Windows Picture 2

Click Browse… (Browse).

How to Execute batch file from command line on Windows Picture 3How to Execute batch file from command line on Windows Picture 3

Navigate to the folder containing the batch file.

How to Execute batch file from command line on Windows Picture 4How to Execute batch file from command line on Windows Picture 4

Click on the batch file to select. The file will be highlighted.

How to Execute batch file from command line on Windows Picture 5How to Execute batch file from command line on Windows Picture 5

Click Open . The full path to the batch file will be pasted into the Run dialog box.

How to Execute batch file from command line on Windows Picture 6How to Execute batch file from command line on Windows Picture 6

Click OK . The batch file will open in a terminal window and execute. When the file finishes running, a line will appear at the bottom of the window with the content 'Press any key to continue'.

How to Execute batch file from command line on Windows Picture 7How to Execute batch file from command line on Windows Picture 7

Press any key. The terminal window will close after the command executes.

Use the Terminal window

How to Execute batch file from command line on Windows Picture 8How to Execute batch file from command line on Windows Picture 8

Click the menu, which is usually located in the lower left corner of the screen.

How to Execute batch file from command line on Windows Picture 9How to Execute batch file from command line on Windows Picture 9

Type cmdin the search bar. A list of matching results will appear.

How to Execute batch file from command line on Windows Picture 10How to Execute batch file from command line on Windows Picture 10

Right click on Command Prompt . A menu will appear.

How to Execute batch file from command line on Windows Picture 11How to Execute batch file from command line on Windows Picture 11

Click Run as Administrator . A confirmation message will appear.

How to Execute batch file from command line on Windows Picture 12How to Execute batch file from command line on Windows Picture 12

Click Yes . The administrator command line will open.

How to Execute batch file from command line on Windows Picture 13How to Execute batch file from command line on Windows Picture 13

Enter cdalong with the full path to the folder containing the .BAT file. Here is an example:

If the batch file is on your desktop, type cd UsersYourLoginNameDesktop.

If the file is in the downloads folder, enter cd UsersYourLoginNameDownloads.

If you don't know the login name, type cd Usersand click ↵ Enterto access the Users user folder, then type dirand click ↵ Enterto see the login list.

How to Execute batch file from command line on Windows Picture 14How to Execute batch file from command line on Windows Picture 14

Press ↵ Enter. You will be redirected to the folder containing the batch file.

How to Execute batch file from command line on Windows Picture 15How to Execute batch file from command line on Windows Picture 15

Enter the batch file name. For example, if the file is named 'program.bat,' you type program.bat.

If you don't know the file name, enter the command dirand click ↵ Enterto see the files in the folder. You will see the file you are looking for here.

How to Execute batch file from command line on Windows Picture 16How to Execute batch file from command line on Windows Picture 16

Press ↵ Enter. The batch file will execute.

5 ★ | 2 Vote