starting a windows executable via batch script, exe not in Program Files

batch-file, command-line, windows

Solution

you are doing it perfectly :-)

the executable is probably looking for this file in the "current working directory", which is being set, when you "cd" to it before.

you can set your working directory manually by creating a shortcut to your batch file; right click; properties.

edit:

you can also set your current working directory using the `start` command:

start "Title" /D "C:\WeirdProgram\WeirdProgramModule\" "weirdmodule.exe"

edit:

If you like to pass params, just add them to the executable filename as you would in a regular shortcut:

start "Title" /D "C:\WeirdProgram\WeirdProgramModule\" "weirdmodule.exe" "param1 param2"

or

start "Title" /D "C:\WeirdProgram\WeirdProgramModule\" "weirdmodule.exe param1 param2"

For reference, the syntax is described here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true.

Problem

This is probably batch scripting 101, but I can't find any clear explanation/documentation on why this is happening or if my workaround is actually the solution. So basically any terminology or links to good sources is really appreciated. So I have a program I want to execute via batch script (along with several other programs). It's the only one where the `exe` is not in a `Program Files` folder. I can get it to start like this: ``` C:\WeirdProgram\WeirdProgramModule\weirdmodule.exe ``` But I get an error along the lines of: ``` Run-time Error '3024': Could not find file C:\Users\MyUserName\Desktop\ModuleSettings.mdb ``` So it seems that the program is looking for its settings files from the same location that the batch script starts up. Given that I finally got everything to work by doing the following: ``` cd C:\WeirdProgram\WeirdProgramModule\ weirdmodule.exe ``` That works fine, and it's not the end of the world to have to go this route (just one extra line), but I've convinced myself that I'm doing something wrong based on lack of basic understanding. Anybody know or can point me to why it works this way? Oh, and doing the following: ``` start "C:\WeirdProgram\WeirdProgramModule\weirdmodule.exe" ``` doesn't do anything at all. Thanks,

Original source