Fixed There is Batch breaking bug in TCC LE (x64)

Aug 10, 2015
4
0
#1
Bug is tested and repeated with two different Win 7 Pro and Win 7 Home computers with TCC LE v14.00.1 & v13.06.77.

There is difference at output of echo %ProgramFiles(x86)% command when it is executed with TCC LE and standard Windows 7 CMD console. When using TCC LE, single spacebar before (x86) is missing, so output value is invalid... See picture below.


 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,570
46
Albuquerque, NM
prospero.unm.edu
#2
That behavior is because TCC doesn't consider the parentheses valid characters in an environment variable name. You get the value of the variable %PROGRAMFILES, followed by the literal string "(X86)". The final percent sign does not introduce a variable name, and is ignored.

You can read the value of that variable using the square-brackets syntax:
Code:
echo %[programfiles(x86)]
If you need it often, you can save it to a variable with a nicer name:
Code:
set programfiles86=%[programfiles(x86)]
 
Aug 10, 2015
4
0
#3
Thanks about your answer.

So, there is no any ways that are compliant with both of them (TCC LE and CMD)?
Is there any TCC LE settings that will help to go around with this?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,570
46
Albuquerque, NM
prospero.unm.edu
#4
There is the CmdVariables .INI directive. If you put CmdVariables=Yes in your .INI file, somewhere in the [4NT] section, and restart, you can use variable names containing parentheses, spaces, and other problematic characters. But: you must use both a leading and a trailing percent sign, as in CMD.EXE. Note that this affects both environment variables and internal variables, breaking compatibility with the vast majority of Take Command (and 4NT, and 4DOS) batch files! I personally do not recommend this approach. In my personal opinion, it would be a lot easier just to copy that one problematic variable into another one.

If you look at the top of this forum, you'll see a couple of 'pinned' threads. The first one covers compatibility directives.