Fixed Change in behavior of variable expansion between 16 and 17

Aug 21, 2014
I had some scripts that was similar to this that did not close a variable in a set statement that stopped working in TCC 17.

Here is a simple batch files that gets the path of the script and removes the trailing backslash:
rem Get the path from our script and remove the trailing \
set ROOT_DIR=%~dp0
set ROOT_DIR=%ROOT_DIR:~0,-1%
echo Root is %ROOT_DIR%

On cmd.exe (Windows 8.1), it does this:

E:\Temp>rem Get the path from our script and remove the trailing \

E:\Temp>set ROOT_DIR=E:\Temp\

E:\Temp>set ROOT_DIR=E:\Temp

E:\Temp>echo Root is E:\Temp
Root is E:\Temp

On TCC 16 it does the same thing as cmd.exe:
rem Get the path from our script and remove the trailing \
set ROOT_DIR=E:\Temp\
set ROOT_DIR=E:\Temp
echo Root is E:\Temp
Root is E:\Temp

On TCC 17, it does this and hangs waiting for the user prompt:
rem Get the path from our script and remove the trailing \
set ROOT_DIR=E:\Temp\

Cancel batch job E:\Temp\test.bat ? (Y/N/A) :
Aug 21, 2014
Even when you close the variable expansion, it only works if you run it from the directory that the script is in (E:\Temp in the example above). If you run it in another directory (e.g., run E:\temp\test.bat from D:\Temp), then it stops after the first set ROOT_DIR line.


Senior IT Security Consultant
May 28, 2008
Confirmed CMD's substrings expansion isn't working in build 53 (or 27 - had an older install on another PC).

variable substitution still works. i.e. :


But of course that replaces all backslash chars with nothing. Just showing that it works. :)

For now in the few I have that don't immediately spawn CMD for their work (most where re-written as BTMs long ago but had a few that were just too big to change or re-write everything that would need changing - and used by others without TCMD) I have changed to use something like this to make it work both under CMD and TCC:

rem Get the path from our script and remove the trailing \
set ROOT_DIR=%~dp0
If NOT "%@EVAL[1+1]" == "2" (
  set ROOT_DIR=%ROOT_DIR:~0,-1%
  Goto :Bye
) Else (
If "%@RIGHT[1,%ROOT_DIR]" == "\" Set ROOT_DIR=%@LEFT[-1,%ROOT_DIR]
echo Root is %ROOT_DIR%
Similar threads
Thread starter Title Forum Replies Date
H Behavior change re piping a string to a Java program Support 1
Jay Sage Change in Behavior of Activate Command Support 4
Peter Bratton @ping behavior change Support 2
R History window wrong size, can't remember size change Support 12
Alpengreis [FORUM] After change the font, bold is without effect Support 7
R How to? Change TCMD tab font size in window menu Support 3
E How to change window title tcmd window - not tcc window Support 1
Alpengreis Small things to change in installer and after installed Everything Support 0
Charles Dye File completion change Support 11
T Change language in script Support 4
I Change value of a variable while debugging Support 3
T Change language after installation Support 4
WadeHatler Fixed Breaking change in Expression evaluation (.and.) in v17 Support 6
Peter Bratton Change in scrput behaviour Support 4
A How to? Can't change directory ("cd") into system hidden files Support 13
J Change folder TCC starts in Support 2
vefatica A small change Support 7
ehab aboudaya How to? change ALT-F6 to another key Support 1
S How to? Change thread prefix? Easy "create thread" method? Support 8
S Terminology change Support 2
T signaling firstcondition and cannot change colors Support 8
newbie Change percent-sign to anything-else in filename Support 24
nikbackm Change format of DIR totals Support 3
Stefano Piccardi did the forum software change in the last two days? Support 2
nikbackm LocalHistory change Support 3
H @XMLNODES - New behavior? Support 3
Jesse Heines Strange Line Wrapping Behavior Support 14
Jay Sage Baffling Behavior With TPIPE Support 5
D Pasting Unicode data has different behavior on TCC and CMD Support 2
P "Set" command behavior - a bug? Support 3
P LOG command behavior Support 3
I Puzzling Behavior of TDRV and DEL Support 2
N Fixed Strange dir behavior Support 6
A Inconsistent @WINPOS // ACTIVATE /POS= behavior Support 0
P Strange mouse behavior with list Support 2
R Find in screen buffer - find next behavior Support 0
D v20 code page behavior changes Support 2
D Strange DO behavior with /O Support 5
deleyd Fixed Behavior different than CMD Support 1
jwiede Difference in "FOR /F" behavior (?) Support 1
R Difference in behavior of RMDIR vs. CMD.EXE? Support 5
D Unexpected behavior Support 8
D Bash-like Esc->Backspace behavior Support 4
C ZIP behavior Support 5
Charles Dye Odd behavior after using OPTION "Advanced" tab Support 2
C odd behavior of "dir" Support 0
M How to? Work around an unexpected and very inconvenient behavior of TCC... Support 26
A expected behavior of move /sx Support 14
M WAD A complaint regarding a very irritating TCC installation behavior... (Bug?) Support 4
S Inexplicable behavior difference in nearly identical shortcuts Support 6

Similar threads