Run exe from current directory in batch

时光怂恿深爱的人放手 提交于 2020-01-17 04:15:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!