How can I get batch files to run through the new Windows Terminal? [closed]

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:

  1. Open regedit and navigate to HKEY_CLASSES_ROOT\batfile\shell key.
  2. Create a key with the name wtopen and the default value Open with Windows Terminal:

RegEdit batfile shell commands

  1. 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:

Windows explorer BAT file right click

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)