Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In first.bat, I use

var5=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\
CALL scripts\vc64.bat %var5%

And in scripts\vc64.bat, I use

SET var6=%1vcvarsx86_amd64.bat
CALL %var6%

But I get : 'C:\Programvcvarsx86_amd64.bat' is not internal or external command..... error.

If the path assigned to var5 has no space, then it is fine.

I tried several combination of quotations and %1vcvarsx86_amd64.bat, but no change.

How do I make it works with path with spaces?


To be more precise, suppose it is C:\a b c\

In first.bat: 
     SET var6=C:\a b c\  =====>  '"C:\avcvarsx86_amd64.bat"' is not.....`
     SET var6="C:\a b c\" ====>   There should not be a b
     SET var6=C:\a\ b\ c\ ====>    Can't find the specified path
     SET var6=C:\a b c\ + Using "%var6" ====> There should not be a b

Update: Here is an example. Change a b to ab works.

call.bat in C:\

@ECHO OFF

SET var5=C:\a b\
CALL C:\1.bat "%var5%"

pause

1.bat in C:\

@ECHO OFF

SET var6=%~1Test.bat
CALL %var6%

RMDIR /S C:\NoWorry

Test.bat in C:\a b Test.bat in C:\ab

@ECHO OFF

RMDIR /S C:\ThereIsNoSuchFolder
share|improve this question
    
Have you tried escaping the single spaces with backslashes (bla\ blub) or enclosing the whole path in quotes ("bla blub")? – feeela Jan 21 '13 at 11:43
up vote 3 down vote accepted

To pass parameters with spaces you need to quote the parameter, then you can remove the quotes using %~1.

So the full script would look like

SET var5=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\
CALL scripts\vc64.bat "%var5%"

SET var6=%~1vcvarsx86_amd64.bat
CALL %var6%
share|improve this answer
    
This gives me 1> There should not be Files。 – user565739 Jan 21 '13 at 11:59
    
It works fine for me, I was missing a set in the answer, try now. – Bali C Jan 21 '13 at 12:18
    
Using "%var5" just give errors like There should not be..... I don't know why. – user565739 Jan 21 '13 at 13:03
    
I mean use quote with %(variable name) just gives me error and it can't call vc64.bat. Without the quotes, it can call vc64.bat, but the parameter is not good. – user565739 Jan 21 '13 at 13:04
    
You need to use "%var5%" with a % sign at each side. – Bali C Jan 21 '13 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .