changing PATH with bracket

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
 
F

foxidrive

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%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top