问题
I'm trying to run 2 *.exe files from whatever directory the batch file is located in. Commands:
@echo off
:A
cls
Echo programs
start %1myprogram.exe
start %1myprogram1.exe
exit
This works perfect when I open my batch file simply by double clicking it, but it doesn't work when I run the batch file as administrator. I need to do this as the two exe's have to have administrator privileges. I suspect this error occurs because it runs the batch file as if it were in the SYSTEM32 folder. Is this correct?
Thanks for your help! Erik
回答1:
Although the answer is in the comments, it should be as an actual answer so that this question is removed from the "unanswered" list.
@echo off
:A
cls
echo programs
cd %~dp0
start %1myprogram.exe
start %1myprogram1.exe
exit
来源:https://stackoverflow.com/questions/27386658/run-exe-from-current-directory-in-batch