%ProgramFiles(x86)% returns different values in TCC and CMD

#1
When I type this...

echo %ProgramFiles(x86)%

...from CMD in 64-bit Windows 7 it returns the value:

C:\Program Files (x86)

When I type exactly the same ting from TakeCommand 11, in the same environment, it return this:

C:\Program Files(x86)


As far as I can tell, TakeCommand takes the parenthesis as an endpoint for the variable name and return the value of %ProgramFiles% followed by the literal text "(x86)", while CMD sees the full variable name %ProgramFiles(x86)% and returns the value for that.

This is causing me serious problems. Is this a bug? Is there a way to work around it? Escaping the parenthesis does not work. I'm not sure what else to try.

--Bob Q
 
#2
echo %[ProgramFiles(x86)]

On Mon, 31 May 2010 15:12:10 -0400, bquinlan <> wrote:

|When I type this...
|
|echo %ProgramFiles(x86)%
|
|...from CMD in 64-bit Windows 7 it returns the value:
|
|C:\Program Files (x86)
|
|When I type exactly the same ting from TakeCommand 11, in the same environment, it return this:
|
|C:\Program Files(x86)
|
|
|As far as I can tell, TakeCommand takes the parenthesis as an endpoint for the variable name and return the value of %ProgramFiles% followed by the literal text "(x86)", while CMD sees the full variable name %ProgramFiles(x86)% and returns the value for that.
|
|This is causing me serious problems. Is this a bug? Is there a way to work around it? Escaping the parenthesis does not work. I'm not sure what else to try.
--
- Vince
 

dim

Dimitry Andric
May 31, 2008
204
1
Netherlands
#3
On 2010-05-31 21:30, vefatica wrote:

> echo %[ProgramFiles(x86)]
For .bat files that need to run under CMD and TCC, I use this:

set PFDir32=%ProgramFiles(x86)%
if not "%_4VER%" == "" set PFDir32=%[ProgramFiles(x86)]%

From there on, use %PFDir32% to point to the 32-bit Program Files dir.
 

rconn

Administrator
Staff member
May 14, 2008
10,504
94
#4
> When I type this...
>
> echo %ProgramFiles(x86)%
>
> ...from CMD in 64-bit Windows 7 it returns the value:
>
> C:\Program Files (x86)
>
> When I type exactly the same ting from TakeCommand 11, in the same
> environment, it return this:
>
> C:\Program Files(x86)
>
>
> As far as I can tell, TakeCommand takes the parenthesis as an endpoint
> for the variable name and return the value of %ProgramFiles% followed
> by the literal text "(x86)", while CMD sees the full variable name
> %ProgramFiles(x86)% and returns the value for that.
>
> This is causing me serious problems. Is this a bug? Is there a way to
> work around it? Escaping the parenthesis does not work. I'm not sure
> what else to try.
Not a bug. CMD requires both leading and trailing %'s, so it assumes that
everything within is part of the variable name. TCC allows a single leading
%, so it has to break on whitespace and what would normally be invalid
variable name characters (like the '(').

You can pass the name with dubious characters included by using the %[]
syntax; i.e.:

Echo %[ProgramFiles(x86)]

Rex Conn
JP Software