By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,694 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,694 IT Pros & Developers. It's quick & easy.

how to define working directory of external program when starting it.

P: 2
I have the following problem:
a program, located on drive a known drive (for example lets say drive C:) needs to execute a program on an unknown different drive (a USB device which doesn't have the same drive letter in each PC).
Locating this program isn't the problem, I'm just letting my main application check the root directory's of all drives currently in use (i know the name and that it's in the root directory).
but now comes the problem, the 'program' (which is a cmd file) needs to write something to the directory it's in, but when writing to './' it will write to the execution directory of my main program. when using the "cd\" command i can let it write to the root but than it's still the wrong drive.
As far as i know it's impossible to get the current drive letter from a .cmd file so the only solution is starting the .cmd file as if it was executed from the directory it's in.
(like the 'Start in' field when defining the properties of a shortcut)

I am currently using Dev C++, the .cmd file has to be executed hidden because the main program is a background worker and i don't want an ugly black screen flashing by. (currently using the SW_HIDE parameter to do this when creating a thread)

OS is windows xp
if you need any more info just post it.

thanks in advance
Aug 29 '07 #1
Share this Question
Share on Google+
1 Reply


P: 2
Never mind, already found out that it is possible to specify the current dir when using the CreateProcess API while maintaining the hidden atribute if you change startup info of the process,
Aug 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.