I guess you refer to teamcity buildstep If
you want to escape the percent sign from being expanded one way
is to double the percentsign which is also a method of delayed
expansion. The exclamation mark is the the replacement char for
the percent sign when using setlocal EnableDelayedExpansion
It's not clear what you are trying to accomplish with your code.
In cmd the \n replacement won't work.
If your intention is to simply pass the % unchanged through an
echo in cmd the doubling should suffice. If delayed expansion is
enabled you may have to escape the exclamation mark with a caret
^!
This code :
@Echo off&setlocal EnableDelayedExpansion
Set Build=C:\Test\Build""secondline
set word=\\
set LF=^
rem The TWO empty lines above are required
rem See http://stackoverflow.com/a/5642300/6811411
set Build2=%Build:\=!word!%
set Build2=%Build2:""=^^!LF^^!%
Echo Build =%Build%
Echo Build2=%Build2%
Produces this output here:
Build =C:\Test\Build""secondline
Build2=C:\\Test\\Build
secondline