Welcome!

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

SignUp Now!

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

Sep
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.
 
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
 
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: 272
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....
 
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?
 
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?

TCMD.EXE starts a new instance of TCC.EXE in a tab window.
 

Similar threads

Back
Top