changing PATH with bracket

  • Thread starter Thread starter Kok Yong Lee
  • Start date Start date
K

Kok Yong Lee

Hi there,

I have a batch file need to modify the env path according to a keyword
supplied by user during run time to change the PATH; e.g. mybat debug, mybat
optimize.

However on certain machine, especially x64 machine, the bracket in the PATH
has caused me a lot of grief.

for example in the code snippet below, if I run it it always error out as
"\fred was unexpected at this time.".

Just wodered are there any ways to get around the bracket issue?

thanks.


snippet
 
Hi there,

I have a batch file need to modify the env path according to a keyword
supplied by user during run time to change the PATH; e.g. mybat debug, mybat
optimize.

However on certain machine, especially x64 machine, the bracket in the PATH
has caused me a lot of grief.

for example in the code snippet below, if I run it it always error out as
"\fred was unexpected at this time.".

Just wodered are there any ways to get around the bracket issue?

thanks.


snippet
----------------
set path=c:\program files(x68)\fred;%PATH%
if /i .%1 == .optimize (
set path=optimize;%PATH%
)

Ditch the parenthesis:

@echo off
set path=c:\program files^(x68^)\fred;%PATH%
if /i .%1 == .optimize set path=optimize;%PATH%
echo %path%
 
Back
Top