Reputation: 195
To recreate my problem you need to understand that I have next files in 2 folders.
K:\Script.bat
K:\Project\PortChanger.exe
K:\Project\settings.xml
I want to launch PortChanger.exe using Script.bat that contains next line:
start "K:\Project\PortChanger.exe"
This script is actually executing Program.exe, but my program throws me exception since PortChanger.exe can't find Settings.xml.
How can I launch PortChanger.exe from "K:\Project\", not from "K:\"? Now it seems like .BAT taking .EXE code and just running it where .BAT is locating.
Upvotes: 1
Views: 2658
Reputation: 38708
You could use Start
with its /D
option:
Start "" /D "K:\Project" "K:\Project\PortChanger.exe"
Open a Command Prompt window and enter start /?
to read its usage information.
Upvotes: 2
Reputation:
I would suggest you rather use pushd
and popd
@echo off
pushd "K:\Project"
start "" PortChanger.exe
popd
pushd
will change to the directory, launch the executable from it, then popd
will return to the previous directory stored.
Upvotes: 1