We help IT Professionals succeed at work.

set the working directory properly

771 Views
Last Modified: 2012-06-21
Hello I am trying to launch an .exe file from a batch file on a shared folder. The exe looks for a config file and if its present it uses that file to do a automated install. The .bat , .exe and .cfg files are all in the same shared folder. If I launch the exe without thout using the .bat file everything works as it should. If I double click on the .bat file the exe doesn't see the config file and prompts for informtion rather than a automated install. I believe the issue is with setting the working directory in the .bat file so it works over the network to the shared folder. I have found some information but I am unclear how to implement it. %cd% %~dp0   Below is the link from the .bat file.

\\servername\ClientApps\Install\Setup.exe
Comment
Watch Question

Out of interest, are you using the full UNC path for the config file too when it's referenced?

Author

Commented:
The only path in the config file is the installation path. There is no UNC path in the config file.
Sorry, I didn't mean IN the config file, I meant in the exe when the config file is referenced... So when the exe is looking for <filename>.cfg, is it referenced using a full UNC path or just by file name?
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Ops Team Office 365/Messaging
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I added a net use command to map the shared folder as a network drive and tried to launch it again but I still get prompted for the information meaning it still doesn't see the config file. How can I set the working directory after the drive is mapped?

Author

Commented:
I didn't see your last post untill after I posted.

Author

Commented:
ok I found the solution on the link.

PushD \\server\ClientApps\Install\

start /wait Setup.exe

PopD

Thanks for everyones help.

Author

Commented:
Here is the soluiton.
PushD \\server\ClientApps\Install\

start /wait Setup.exe

PopD
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.