You can have this behaviour on double click by changing HKEY_CLASSES_ROOT\batfile\shell\open\command
default value from:
"%1" %*
to:
"C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe" -p "Command Prompt" "%1" %*
or by using ftype
command:
ftype batfile="C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe" -p "Command Prompt" "%1" %*
You have to change <user>
with the current user name directory and of course, this wt.exe
path (C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\
) is if you’ve installed Windows Terminal from Microsoft Store, if you haven’t, then you have to find the path to wt.exe
and use that instead. Windows enviroment variables %LOCALAPPDATA%
and %USERPROFILE%
did not work for me, so I’m using full path here.
You can create a registry entry to have an option to opem a BAT
file using Windows Terminal and having it running with CMD
:
- Open
regedit
and navigate toHKEY_CLASSES_ROOT\batfile\shell
key. - Create a key with the name
wtopen
and the default valueOpen with Windows Terminal
:
- Create a subkey
HKEY_CLASSES_ROOT\batfile\shell\wtopen\command
with the default value:"C:\Users\<user>\AppData\Local\Microsoft\WindowsApps\wt.exe" -p "Command Prompt" "%1" %*
And now you’ll have a new entry “Open with Windows Terminal” when you right click on BAT
files and when you click it it will open a new Windows Terminal with a Command Prompt panel running the selected batch file:
Tested with Windows Terminal 0.11.1121.0
The default name for the Command Prompt (cmd
) profile is “Command Prompt”. You’ll have to change it using the -p "<name>"
parameter if you have other name than the default.