0

I have this batch file:

set LOCAL_ROOT="%~dp0" 
setx BOOST_ROOT             "%LOCAL_ROOT%\boost"

when I run this batch file, I am getting this value set to BOOST_ROOT

BOOST_ROOT=D:\Local\ boost

as can be seen, there is a space in path which should not exist. How can I remove it?

1

1 Answer 1

1

This is what you need:

@echo off
set LOCAL_ROOT=%~dp0
setx BOOST_ROOT="%LOCAL_ROOT%boost"

REM the next two lines are for debugging, remove from final batch file:
echo %BOOST_ROOT%
pause

Alternatively, without declaring the first variable at all:

@echo off
setx BOOST_ROOT="%~dp0boost"

You don't need the quotes while declaring LOCAL_ROOT, and your code appears to have a few formatting errors. Keep in mind that %~dp0 includes a trailing backslash.

You must log in to answer this question.

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