Help running batchfile from network share with spaces in path

jspade_69
jspade_69 used Ask the Experts™
on
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:

\\servername\applicationfolder\Office\

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.

Example:

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?

Thanks
OfficeCleanInstall.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
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".

Commented:
You can also just not use start ... If you are doing start / wait it isn't a lot different...

Steve

Commented:
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.

Steve
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
"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.

Commented:
oBdA... good point, sometimes better, sometimes the same.

Author

Commented:
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.

Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial