DOS BAT Quotes

August 6, 2010 at 01:55:27
Specs: Windows XP
Hi all,

I've got a simple batch file that takes many arguments. I'm calling this from another batch file and it looks like this:

MyBatchFile.bat "PARAM_1" Param2 y n n "C:\Program Files\Path With Spaces"

However I get this error message:
Files\Microsoft was unexpected at this time.

I've also tried ""C:\Progra... but that doesn't work either. I'd appreciate any guidance on what I'm doing wrong.


See More: DOS BAT Quotes

Report •

August 6, 2010 at 07:04:55
From your post it seems the problem is inside the called batch not in your calling statement.

If the batch you are calling doesn't expect parameyers with embedded spaces it will return an error during its run. The only way to discover this is to walk through the code and see if there are parameters sensible to spaces.

Report •

August 6, 2010 at 08:45:05

You are right. I've added ECHO into my called batch but it's a bit strange:

IF "%6"=="" (
SET /P MY_PATH="Please specify the path: "
) ELSE (

So ECHO %6 works but doesn't do ECHO %MY_PATH%. So it's failing at %6. ECHO %6 has the path with quotes. Is that what the problem is then? Any suggestions how I can get round it? Should I try to strip the quotes?

Thanks for your help so far.


Report •

August 6, 2010 at 08:48:25
This isn't part of a FOR, IF, or other nested command, is it?

Report •

Related Solutions

August 6, 2010 at 08:59:44
Figured it out.

IF "%6"=="" (
should have been
IF %6=="" (

Thanks for all your help!

Report •

Ask Question