Run all .CMD batch files with CMD.EXE

May 26, 2008
537
4
Is there a convenient way to have TCC execute a *.CMD batch file using CMD.EXE?

I use the .BTM extension when I write a batch file that uses TCC syntax/features, but use .CMD when I write batch files using standard CMD syntax. Because TCC does not perfectly emulate CMD syntax, I am looking for some way to force *.CMD batch files to run using CMD.EXE if I try to execute them at a TCC prompt.
 
May 20, 2009
293
5
57
ITALY
Is there a convenient way to have TCC execute a *.CMD batch file using CMD.EXE?

I use the .BTM extension when I write a batch file that uses TCC syntax/features, but use .CMD when I write batch files using standard CMD syntax. Because TCC does not perfectly emulate CMD syntax, I am looking for some way to force *.CMD batch files to run using CMD.EXE if I try to execute them at a TCC prompt.
On my system the ".cmd" suffix is associated with "cmdfile" (check with "assoc .cmd").
And it is executed directly as cmdfile="%1" %* (check with "ftype cmdfile").
You might test this command:
Code:
ftype cmdfile="C:\Windows\System32\cmd.exe" /c "%1" %*
ftype cmdfile="C:\Windows\System32\cmd.exe" /c "%1" %*
I did not test it (my system is already a mess enough), so be careful, and test it according to You settings (32/64, a system drive that is different from C, and so on).


Regards

Rodolfo Giovanninetti
 
May 26, 2008
537
4
Thank you, but I was looking for a solution that does not modify any system-level associations. In other words just some solution that affects only TCC.
 
May 26, 2008
537
4
Thanks Rex, but it doesn't seem to work for me.

I started a TCC session and used ESET to remove .CMD from PATHEXT. I then typed:

Code:
set .cmd=cmd.exe /c

But when I run a .CMD file from TCC, it is still processed by TCC directly.
 
May 26, 2008
537
4
It was unchecked, so I tried it with that option checked and it behaved the same as far as I can tell. Actually with that option checked my tcstart.btm isn't processed for some reason.
 
May 26, 2008
537
4
I'm guessing it was because .BTM was not included in PATHEXT. In any case it didn't seem to make any difference with how CMD files are processed. TCC still handled it on its own instead of launching cmd.exe
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
It is working for me. How did you run Option? If you run Option from the TakeCommand menu, the settings do not apply to the running instance of TCC. You need to launch a new TCC process. If you run OPTION from within TCC, the settings will affect the current process and any new processes.

And yes, you have to add .BTM to PATHEXT in order to have it execute without specifying an extension. I.e. FOO will give an error but FOO.BTM will run.
 
May 26, 2008
537
4
Ok after more testing I find that it DOES work by using PATHEXT option and setting a .CMD executable extension, but ONLY if I leave off the ".cmd" part when running the batch file. If I try to execute the batch file with the extension present, TCC still processes it instead of using CMD.

Is there a way to avoid this? I often (always?) use filename completion so if I run a batch file it almost always has the extension on it.
 
Oct 29, 2008
88
0
When I write a TCC(LE)-flavor bat file that might be started by cmd I use:
Code:
@echo off
if 01 == 1 goto tccstarthere
"C:\Program Files\JPSoft\TCMD\tcc.exe" /c %0 %*
exit /b %ERRORLEVEL%
:tccstarthere
The converse for one that must run in cmd when started by TCC(LE) should be (untested code)
Code:
@echo off
if not 01 == 1 goto cmdstarthere
"%systemroot\system32\cmd.exe" /c %0 %*
quit %?
:cmdstarthere
TCC (not LE) can use "%@shfolder[37]\cmd.exe" instead of "%systemroot\system32\cmd.exe"
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
The problem with that approach is you are depending upon a quirk in the parser. This has worked since the early days:
Code:
if %@eval[2+2]==4 goto tccstarthere
"C:\Program Files\JPSoft\TCMD\tcc.exe" /c %0 %*
exit /b %ERRORLEVEL%
:tccstarthere

and likewise
Code:
if not %@eval[2+2]==4 goto gotcmd
cmd /c %0 %*
quit %?
:gotcmd
 
May 26, 2008
537
4
Thanks... I am aware of workarounds like that but I was hoping for a more elegant solution.

Too bad I can't seem to figure out how to get TCC to run all *.CMD files using cmd.exe yet
 
May 29, 2008
571
4
Groton, CT
Thanks... I am aware of workarounds like that but I was hoping for a more elegant solution.

Too bad I can't seem to figure out how to get TCC to run all *.CMD files using cmd.exe yet
This is what I use:
Code:
C:\work> assoc .cmd
.cmd=cmdfile

C:\work> ftype cmdfile
cmdfile="C:\Program Files\JPSoft\TCMD\TCC.EXE" /c "%1" %*
 
May 26, 2008
537
4
This is what I use:
Code:
C:\work> assoc .cmd
.cmd=cmdfile

C:\work> ftype cmdfile
cmdfile="C:\Program Files\JPSoft\TCMD\TCC.EXE" /c "%1" %*

That's not what I'm looking for.... I want batch files I type at the TCC command line to run using CMD.EXE instead of TCC if the batch filename ends in .CMD.

The only thing that came close is Rex's suggestion above (modifying PATHEXT and setting up an executable extension in TCC), but it only works if I execute the .CMD batch file while leaving off the extension. If I attempt to run a batch file with its full filename (including .CMD extension), it is still processed by TCC directly.
 
May 20, 2008
11,424
99
Syracuse, NY, USA
It behaves the same way here, and that seems wrong. If there's an executable extension, and the extension is given, then the executable extension should be honored.
 
Similar threads
Thread starter Title Forum Replies Date
vefatica What limit have I run into? Support 9
S How to? Runs start /w in invisible mode OR run program after exit of another one Support 3
Jay Sage Command Will Not Run Using Short Name of Path Support 5
Peter Murschall BDEBUGGER "Run to Cursor" - where is it ? Support 1
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
D What does the file "..\Everything\Run history.csv" store? Support 5
dcantor How to? Can 32-bit TCC be run on a system with 64-bit TCMD and TCC installed? Support 6
G tcedit ist not run in tc 24 file explorer Support 10
A Windows 10 This app can't run on your PC Support 2
P Run as Admin tab in non-elevated Take Command session? Support 9
Roedy run as administrator Support 27
rps Documentation "Copy+Paste+run" question Support 2
Peter Murschall IDE/BDEBUUGER in TCC 22 didn't run Support 7
fpefpe How to? which will run? Support 1
C How to? run a BTM in elevated, inv tcc tab window Support 9
M How to? Run the control panel from a TCC session... Support 2
M How to? Run TCC from Windows Install DVD... Support 2
B Batch file won't run if there is already an instance of TC 17 running Support 9
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10
redwdc btm won't run in ver. 17 but works in ver. 16 Support 11
C How to? run a batch file in administrator mode while debugging in take command software Support 1
Joe Caverly How to? Run DOS .exe's the same way Wine does... Support 3
tmaynard How to? Any way to run a command in a new tab at startup? Support 18
vefatica Why isn't TCSTART.BTM run? Support 8
M Installed but can't run Take Command 16.0 Support 5
Joe Caverly Run As Administrator in TCMD16 Support 3
F Sending "Y" to chkdsk to run on C at next reboot Support 25
T tcc /c "[...]" fails when run from third party terminal Support 11
B Select and run lines from Command Input panel? Support 1
Jay Sage Specified INI File Refuses to Run Support 3
A How to? Run a TCC command from external program Support 2
C How to? create a JPSoft BTM menu to run custom custom batch files Support 2
vefatica Coruption after which BTMs won't run Support 7
M How to? Run a command (alias, actually) on a "timed" basis... Support 13
Joe Caverly Copy Paste Run Support 12
S Fixed TCC.EXE 13.03.47 won't run Support 4
Stefano Piccardi run as limited user Support 2
M How to? Windows 7 - run TCC as admin w/o UAC intercept Support 4
E TCC requires elevation to run Support 2
Jay Sage How to Run Non-Elevated From Elevated TCC Support 1
L How can I run tcmd in terminal window only? Support 13
S Run as Administrator question Support 3
Joe Caverly TCMD12 Beta Expired, TCMD11 will not run Support 7
p.f.moore Run as administrator from TCC Support 2
vefatica Help from IDE fails after a non-debug run Support 5
B TCC doesn't run using another user Support 2
A How to Run the 4NT 8.02 .INI Key Version Support 3
K double click to run btm? Support 2
D TCC won't run telnet on Windows 7 RC1 Support 5
D Can I use TC to run Cygwin? Support 4

Similar threads