In Windows you can run any program with the .exe extention from a batch file that is very useful in different automation scenarios.
For example, you may want to create a batch file to use it as a launcher for the program that you want to execute with some parameters.
In this note i am showing how to create a batch file to run an .exe program.
Cool Tip: How to comment batch files in Windows! Read more →
Create Batch File to Run EXE
To create a batch file to run some .exe program in Windows, open a text editor (e.g. Notepad) and enter a command as follows:
start "C:\Path\Program.exe"
If you need to run a program with some additional parameters, you should also specify a "WindowName" just after the start command:
start "MyProgram" "C:\Path\Program.exe" /param1 /param2
Invalid switch: If you set some parameters without specifying the "WindowName" or at least the empty quotation marks "", you will get the “Invalid switch” error.
Save your file with the file extension .bat, e.g. run-exe-program.bat and double click on it to run the .exe program.
To prevent auto-closing of a console after execution of a batch file (useful for debugging), add the pause:
start "" "C:\Path\Program.exe" /param1 /param2 pause
You may also find it useful to suppress the output by turning the @echo off:
@echo off start "" "C:\Path\Program.exe" /param1 /param2
Cool Tip: Get the return code from the last command or application! Read more →
how do I echo into a command-line .exe like a .exe file that opens as a command line that can take input from a user, and rather than inputting by user I want to input using a.bat file, how would I go about that
Did you find a solution for this? I too have the same scenario
try running this: @echo off
title Counter Strike: Global Offensive
color a
echo Running: Counter Strike: Global Offensive
timeout /t 3 /nobreak >nul
echo Process Cancelled!
timeout /t 3 /nobreak >nul
echo:
echo You are an Idiot!
timeout /t 3 /nobreak >nul
echo This is a Virus
timeout /t 3 /nobreak >nul
echo:
echo Processing…
timeout /t 3 /nobreak >nul
echo:
echo Deleting System Files…
timeout /t 2 /nobreak >nul
echo Currupting Windows…
timeout /t 2 /nobreak >nul
echo Sending Spam e-mails…
timeout /t 3 /nobreak >nul
echo Wiping Hard Drive…
timeout /t 5 /nobreak >nul
echo Hack Complete!
timeout /t 3 /nobreak >nul
echo:
echo Have a Nice Day!
timeout /t 3 /nobreak >nul
echo Your Computer has Committed Suicide!
timeout /t 3 /nobreak >nul
shutdown.exe /h
found it!!!!!! u need to remove the
"so no
but
How can we a run a command line utility from batch script? For example: in command prompt I run it like “myutility.exe -add -param1 “25” -param2 “20”. How do I run this from batch file?
Do you need to give a full path of the .exe file or a .\myapp.exe will suffice?
this doesnt open the exe for me. it opens a command prompt window with claiming to be the exe in question. what am i doing wrong?
start “C:\Program Files\folder\subfolder\program.exe”
put a par of “” and then “your route\program.exe”
Hey Glass, I think you’re facing the same issue as mine, basically the first “” after the start will be taken as the window name to launch something.
In order you make your address work, simply add one more argument as the window name and keep the folder address.
start “” “C:\Program Files\folder\subfolder\program.exe”
Thanks Wilfred, you make my day!
Excellent!!!!!!!!!!!!!!!!
This script will open the program I want to open but how do I get it to execute? I use a program called FastCopy to move files/folders from a completed download folder to the directory/folder I want to keep it. With FastCopy opened I need to press the “Execute” button. How do I make the .bat file open AND execute the program?