Running this batch file
@echo off
set a=some value with (parentheses) inside
if 1 == 1 (
set PATH=%a%
)
gives inside was unexpect
Brackets and variables are always a pain to mix. Use a subroutine instead.
@Echo Off
Set a=some value with (parentheses) inside
If 1 == 1 Call :SetPath
Echo %Path%
Exit /B
:SetPath
Set "Path=%a%"
SetX "Path" "%a%"
Exit /B
I set the variable twice, once using Set for the current shell session, and one using SetX to set it system-wide for future shell sessions. Remove either if they're unneeded.