Running this batch file
@echo off set a=some value with (parentheses) inside if 1 == 1 ( set PATH=%a% )
gives inside was unexpect
inside was unexpect
The ) in %a% is the problem here. You can just do some substitution to escape the ).
)
%a%
@echo off set a=some value with (parentheses) inside if 1 == 1 ( set PATH=%a:)=^)% )