Help running batchfile from network share with spaces in path

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
jspade_69Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
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".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
You can also just not use start ... If you are doing start / wait it isn't a lot different...

Steve
0
Steve KnightIT ConsultancyCommented:
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
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

oBdACommented:
"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.
0
Steve KnightIT ConsultancyCommented:
oBdA... good point, sometimes better, sometimes the same.
0
jspade_69Author 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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.