giving error in path variable declaration

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vinod
Posts: 1
Joined: 24 Sep 2015 07:20

giving error in path variable declaration

#1 Post by vinod » 24 Sep 2015 10:39

Hi,

I am using windows-2008 machine.
In my batch script i have a condition like this,

if %BIT_FLAG% == 32-bit (

set PATH=C:\Program Files (x86)\Teradata\Client\%PKGVERSION%\bin

)

when i run this it is giving me an error..

\Teradata\Client\15.10\bin was unexpected at this time.

it seems it is giving me error due to having parenthesis.. how should i make it work?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: giving error in path variable declaration

#2 Post by Squashman » 24 Sep 2015 10:52

Code: Select all

if %BIT_FLAG% == 32-bit (

set "PATH=C:\Program Files (x86)\Teradata\Client\%PKGVERSION%\bin"

)

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: giving error in path variable declaration

#3 Post by Squashman » 24 Sep 2015 11:04

You may want to consider using a different variable name then PATH because PATH is already a system variable.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: giving error in path variable declaration

#4 Post by foxidrive » 24 Sep 2015 18:48

Or add it to the PATH variable, if that is the reason why you are using the PATH as it is intended.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: giving error in path variable declaration

#5 Post by ShadowThief » 25 Sep 2015 02:14

Alternatively, you could also escape the parentheses around x86 with the ^ character.

Code: Select all

set PATH_VAR=C:\Program Files ^(x86^)\Teradata\Client\%PKGVERSION%\bin


But using quotes like in Squashman's example is better because that way there is no possibility for extra spaces to be accidentally added to the end of the value.

Post Reply