Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Run all .CMD batch files with CMD.EXE

May
550
6
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.
 
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
 
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.
 
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.
 
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.
 
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
 
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.
 
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.
 
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"
 
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
 
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
 
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" %*
 
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.
 
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

Back
Top