I have in the same folder a .bat
and a .exe
file. I couldn't call the .exe
file from the .bat
unless I put the full absolute path to it. Is there a way to don't specify the path?
Create Batch File to Run EXESave your file with the file extension . bat , e.g. run-exe-program. bat and double click on it to run the .exe program.
Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to run a Windows 10 batch file and press Enter: C:\PATH\TO\FOLDER\BATCH-NAME. bat.
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.
What is the current directory in a batch file? Using the variables mentioned here, you can update run1.bat to call app1.exe with the following line: %~dp0app1.exe. (The %~dp0 variable includes a trailing slash.) This will tell the batch file to run the executable from the current batch file's location.
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:
Type a name for the script — for example, first_advanced_batch.bat. After you complete the steps, double-click the .bat file to run it or use the steps below to execute the script with Command Prompt, File Explorer, or Task Scheduler.
Try calling the .exe
with %~dp0
, like this: %~dp0MyProgram.exe
.
%0
contains the full path to the called .bat
file.
~dp
says to get the drive and path, including trailing \
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With