7

If I do:

set dir1= %ProgramFiles%\Backup\files
set dir2= %ProgramFiles%\Backup\settings
set backup = B:\backup
start /b combine_file.exe %dir1% %dir2%

the above example just sees the first part i.e. C:\program and does not include the space yet.

If I do echo %dir1%, it will return the correct path. Where would you put the "" to resolve this problem?

Same problem happens, when you do some thing similar:

set /p somepath=Enter Path
start /b combine_file.exe %dir1%\%somepath%

You'll get an error, because of that space, yet when trying to put "" in, you often get another type of error, because of that. On test I know the example does work as if you pick a directory without spaces or manually put in "" on set /p blah= this works fine.

Pretty sure I'm just missing a simple switch or some thing like /I.

2
  • 1
    start /b combine_file.exe "%dir1%" "%dir2%" should work Commented Jan 30, 2014 at 12:35
  • Yes it did, thank you, I swear down I tried that... I must've been trying to do it on the .exe part too, how retarded. Commented Jan 30, 2014 at 12:49

3 Answers 3

14
set "dir1=%ProgramFiles%\Backup\files"
set "dir2=%ProgramFiles%\Backup\settings"
set "backup=B:\backup"

start /b combine_file.exe "%dir1%" "%dir2%"

set /p "somepath=Enter Path"
start /b combine_file.exe "%dir1%\%somepath%"

In general, use quotes on variable asignation to ensure the spaces are correctly handled, but don't include the quotes inside the values. So, all paths in variables doesn't contain quotes. When the value needs to be used, then, quote the variable.

Sign up to request clarification or add additional context in comments.

Comments

2

start /b combine_file.exe "%dir1%" "%dir2%" should work

Comments

0

You can try put "" on SET command:

set "dir1=%ProgramFiles%\Backup\files"
set "dir2= %ProgramFiles%\Backup\settings"
set /p "somepath=Enter Path"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.