.BAT works in TCC-RT 25, but not in TCC-RT 26

I have the following .BAT file;
@echo off
set "beginJS=mshta "javascript:close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write("
set "endJS=));""
for /f %%N in (
  '%beginJS% \u0047etObject('winmgmts:').ExecQuery('Select * from Win32_PerfFormattedData_PerfOS_Memory').ItemIndex(0).AvailableBytes %endJS%'
) do set free_mem=%%N
echo free_mem=%free_mem%

The above runs and returns the correct results in CMD and PowerShell, and TCC-RT 25;
e:\utils>"C:\Program Files\JPSoft\TCC_RT_25\tcc.exe" /q "E:\Utils\testhta.bat"

Version TCC-RT 25.00.27 x64

However, it does not return the correct results in TCC-RT 26;
e:\utils>"C:\Program Files\JPSoft\TCC_RT_26\tcc.exe" /q "E:\Utils\testhta.bat"

e:\utils>"C:\Program Files\JPSoft\TCC_RT_26\tcc.exe" /q "e:\utils\whatver.btm"
     _x64: 1
   _admin: 1
_elevated: 1

TCC-RT  26.01.35 x64   Windows 10 [Version 10.0.18362.720]
BuildNumber  Caption                   CSDVersion  OSArchitecture  Version
18362        Microsoft Windows 10 Pro              64-bit          10.0.18362

May 20, 2008
Syracuse, NY, USA
Here, that batfile works only in CMD (failing in TCC 24, 25, and 26, and in PowerShell).

If I put the "FOR ... IN ( ... ) DO ... " statement all on one line it also fails in CMD (no output at all).

HeeHee!! When I changed "\u0047" to "G" and tried running it in TC24 I got this.

Yes, mshta.exe worked fine in Windows 7 and earlier versions of Windows 10, but it is frequently detected now as a virus (false-positive) by several anti-virus programs.

It still works fine (no virus alert) on my system for some things;
mshta.exe "javascript:clipboardData.setData('text','Joe');close()"
mshta.exe vbscript:Execute("msgbox ""message"",0,""title"":close")
mshta javascript:alert("Message\n\nMultiple\nLines\nIn\nThis\nDialog\!");close();

May 20, 2008
Syracuse, NY, USA
That security alert gives a hint about what's happening. TCC24 apparently stops parsing FOR's set at the single quote following "winmgmts".


Staff member
May 14, 2008
That batch file doesn't work in any version of TCC.

The problem is the multiple nested ( and ) and ' characters are confusing the FOR parser. I might have a fix, but I'm going to need to test it for a bit to make sure it doesn't break existing behavior.
Similar threads
Thread starter Title Forum Replies Date
I How to? Bat Works but BTM Doesn't Support 6
C .bat files works in cmd.exe, not in TCMD Support 6
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
I BTM slower than BAT? Support 14
S incorrect message at start Cancel batch job 4START.bat ? (Y/N/A) : Support 1
S Debugger Bat file call history Support 9
E How to? use Executable Extensions: .bat and .cmd Support 8
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10
C Documentation .CMD .BAT .BTM Support 15
w_krieger WAD 4DOS and benny.bat Support 2
A Stupid, obvious question - launch a BAT with TC Support 10
Mordachai How to get a TC interface instead of a console for .btm, .bat, ? Support 10
A WAD BOM printed on command line from BAT file Support 5
C Simple .bat question - dump contents of 2 dimensional array Support 2
CWBillow TCC and CMD / BAT files Support 3
C .CMD .vs. .BAT Support 3
B Strange handling of a .BAT file Support 5
Roedy bat file properties Support 1
T VIEW only works from command line Support 14
D Alias with setdos no longer works Support 21
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
Phileosophos Enumshares works sometimes Support 16
I findstr works in cmd but not in tcc Support 5
Dmitry L. Kobyakov WAD Start /pgm "name.htm" works improperly Support 4
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
Joe Caverly Works in debugger, not from cmd line Support 1
M "less" program that works in TC 18 Support 12
Joe Caverly Echo message works without the space? Support 3
cxxl dir /s works in mysterious ways :( Support 4
J WAD setarray "/f" only works on first one Support 1
M Console-Mode (*.exe) works in TCC, not in TCMD Support 2
redwdc btm won't run in ver. 17 but works in ver. 16 Support 11
vefatica Alias works differenltly v16 vs. v17 Support 13
C FFind /w works but FFind /= doesn't? Support 2
R Drag to BTM no longer works in Windows 8.1 Support 10
Frank @replace works case sensitive Support 5
D TPIPE works without being in path, but not V; aemail Support 8
noahcoad c:/hello.txt works in cmd.exe but not tcc.exe Support 1
K Ctrl-D alias no longer works Support 4
R %+ works differently after upgrade Support 3
Joe Caverly Clearing a section of the screen works in CMD, not in TC Support 2
C COMSPEC constantly reset to TCC.EXE Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
C How to? starting TCC/TCMD v25 Support 2
CWBillow TCC and TCMD in Powershell Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0

Similar threads