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

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

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

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

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

Click Browse… (Browse).

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

Navigate to the folder containing the batch file.

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

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

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

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

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

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'.

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

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

Use the Terminal window

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

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

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

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

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

Right click on Command Prompt . A menu will appear.

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

Click Run as Administrator . A confirmation message will appear.

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

Click Yes . The administrator command line will open.

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

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.

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

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

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

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.

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

Press ↵ Enter. The batch file will execute.

Update 19 June 2024
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile