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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With