Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Help running batchfile from network share with spaces in path

Posted on 2014-08-01
Medium Priority
Last Modified: 2015-05-01
I have a batch file that runs from a network share....as long as the network share path doesn't have a space then the %~d0%~p0 function works beautifully.
Network path example Example:


But if the paths has a space, then the function doesn't work:

Network path example 2:

\\servername\application folder\Office\

If I wrap the %~d0%~p0 in quotes like so - "%~d0%~p0" then it see the path, but I have a start /wait command before the exe and it's screws that up and the exe doesn't run it just opens up a second command window.


Start /wait "%~d0%~p0"

It will run without the start /wait but I need to have that to run other things in the batch file after the exe finishes.... can any one help?

Question by:jspade_69
  • 3
  • 2
LVL 86

Accepted Solution

oBdA earned 2000 total points
ID: 40234556
You do need quotes, but  for "start" you need an additional set of quotes, otherwise it will take the quoted path as window title. Try
start "" /wait "%~dp0"

Open in new window

Note that you can combine the different expansion options, so "%~d0%~p0" is the same as "%~dp0".
LVL 43

Expert Comment

by:Steve Knight
ID: 40234913
You can also just not use start ... If you are doing start / wait it isn't a lot different...

LVL 43

Expert Comment

by:Steve Knight
ID: 40234920
BTW also if you don't know use

Pushd "%~dp0" and it will map a temporary drive if ran from a unc path so the current dir is the one the batch ran from.

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

LVL 86

Expert Comment

ID: 40234977
"start /wait" can be a lot different from just calling the program.
For example, if you invoke msiexec.exe from a batch without "start", msiexec will return immediately and run the install in the background (and obviously without returning an errorlevel).
Only "start /wait msiexec.exe ..." will actually wait until the installation is done and return an errorlevel.
LVL 43

Expert Comment

by:Steve Knight
ID: 40235272
oBdA... good point, sometimes better, sometimes the same.

Author Comment

ID: 40235555
Thanks guys....I ran it without the start /wait again and this time I was a bit more patient and it ran and continued on with the other steps in the batch file with no problem.


Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question