How to execute programs in the same directory as the windows batch file?

前端 未结 2 1257
执笔经年
执笔经年 2021-01-30 09:54

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

2条回答
  •  梦毁少年i
    2021-01-30 10:33

    I solved this by changing the working directory using pushd at the start of the script and restoring is at the end of the script using popd. This way you can always assume the working directory is the same as the location of the bat file.

    pushd %~dp0
    ProgramInSameFolderAsBat.exe
    popd
    

提交回复
热议问题