1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Support' started by bquinlan, May 31, 2010.

  1. bquinlan

    Joined:
    Aug 23, 2009
    Messages:
    15
    Likes Received:
    0
    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. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,058
    Likes Received:
    30
    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
     
  3. dim

    dim Dimitry Andric

    Joined:
    May 31, 2008
    Messages:
    203
    Likes Received:
    0
    On 2010-05-31 21:30, vefatica wrote:

    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.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,021
    Likes Received:
    84
    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
     

Share This Page