How to? use Executable Extensions: .bat and .cmd

Sep 15, 2008
5
0
Hello,

the following command is not working:
set .bat;.cmd=C:\Windows\system32\cmd.exe /c

Why do I want to set this.
I want that really all .bat files and all .cmd files are really executed from within cmd.exe.

Without this all .bat/.cmd files are executed with tcc.

One possibility is to change ftype batfile and ftype cmdfile.

But doing this every batchfile form within cmd context is started with a sub shell.

And this is not what I want.

Can anyone give me a hint.


best regards
Heiko Elger
 
I've always run this way (with TC only executing .BTM files) simply by not letting the installer associate .BAT or .CMD with Take Command. Thus perhaps the simplest way would be to uninstall TC and reinstall that way??

Alternatively, what I see when I execute ftype is:

cmdfile="%1" %*
batfile="%1" %*

and the associations are:

cmdfile=Windows Command Script
batfile=Windows Batch File

Do they match what you're setting them to??


Oh, and FWIW I don't think that you can change the behaviour for .BAT, .CMD or .BTM via executable extensions, only add behaviour for other extensions.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I believe you can use PATHEXT to do what you want. First you need to enable PathExt in the OPTION dialog. Then set the extensions you want in the PATHEXT environment variable.
The default values for .bat and .cmd are:
Code:
[C:\] assoc .bat
.bat=batfile

[C:\] ftype batfile
batfile=C:\Windows\System32\cmd.exe /C "%1" %*

[C:\] assoc .cmd
.cmd=cmdfile

[C:\] ftype cmdfile
cmdfile=C:\Windows\System32\cmd.exe /C "%1" %*

Now the question is when did you desire for CMD to process those scripts?
  1. When a .BAT file is clicked in Explorer
  2. When a script is invoked from a build tool like Visual Studio
  3. When you are running TCC and you enter the name of a .BAT file on the command line
Use case 1 & 2 are handled by the assoc/ftype settings.

In order for it to work you actually need to remove .BAT and .CMD from your PATHEXT variable. I believe you might have to add .BTM to PATHEXT in order for BTM files to continue to work correctly. Then create executable extensions for .BAT and .CMD.
Code:
set .bat=c:\windows\system32\cmd.exe /c
set .cmd=c:\windows\system32\cmd.exe /c

I tested it by doing this:
Code:
option //PathExt=Yes
set .bat=c:\windows\system32\cmd.exe /c
set PATHEXT=.COM;.EXE;.BTM;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
echo ver>test.bat
test
option //PathExt=No
test
 
Jun 2, 2008
359
4
You might want to check out the tccbatch.btm file in the installation directory.
 
Oct 18, 2009
362
17
Regarding "check out the tccbatch.btm file", that is a one-way program. It can switch to using TCC but it can't switch back.
 
Apr 2, 2011
1,441
10
54
North Carolina, USA
Regarding "check out the tccbatch.btm file", that is a one-way program. It can switch to using TCC but it can't switch back.

If you want to switch back to CMD defaults - maybe you can run the attached RegTweaks.btm with "-undo" ....

It's by Charles Dye - also on the forum....
 

Attachments

  • RegTweaks.btm
    27.2 KB · Views: 82
Apr 2, 2011
1,441
10
54
North Carolina, USA
Regarding "check out the tccbatch.btm file", that is a one-way program. It can switch to using TCC but it can't switch back.

If you want to switch back to CMD defaults - maybe you can run the attached RegTweaks.btm with "-undo" ....

It's by Charles Dye - also on the forum....
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
When Tcmd.exe is set as the handler for .BAT, .CMD, or .BTM files, are the scripts actually handled by tcmd or does it launch TCC and run them from TCC?
 
Similar threads
Thread starter Title Forum Replies Date
C V25 eats STDERR from executable extensions Support 8
M How to set Path variable for non-executable file extensions in 4DOS Support 8
W File completion without space/executable extensions Support 3
dcantor Executable file extensions in V10 b 38 Support 5
David McClelland TCMD 24 & Perl - perl thinks it's own executable is ...\TCMD24\TCC.EXE??? Support 3
T TCHelp executable history? Support 2
Craig Fitzgerald problem with executable extensons with TCC version 19.10.51 x64 Support 3
Jay Sage Executable Extension with Lua Support 5
D Executable load errors suppressed Support 5
P Executable extension problem 2 Support 0
P Executable extension problem 1 Support 7
Phileosophos PDIR to list filenames without extensions? Support 2
CWBillow Context menu extensions for TCC/TCMD v18? Support 1
MikeBaas How to? DIR: supress extensions? Support 5
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
Joe Caverly .BAT works in TCC-RT 25, but not in TCC-RT 26 Support 4
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
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10
I How to? Bat Works but BTM Doesn't Support 6
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
C .bat files works in cmd.exe, not in TCMD Support 6
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

Similar threads