Ei taida tosiaan ainakaan helposti onnistua. Toki voi tehdä oikean painikkeen valikkoon valinnan tuolle:
I have little power shell and cmd scripts that I run now and then. When I click on a bat script, it opens a classic CMD window. When I run a PS1 script, it opens the classic PowerShell window. Is it
superuser.com
Next caveat, while you
probably can modify the default .bat double-click "Open" command, I don't recommend doing so. There
may be other applications (or even Windows functionality) that relies on that default behavior. My recommendation is to
add a right-click "Run in Windows Terminal" option for CMD .bat files, just as we will for PowerShell .ps1 files.
To do so:
- Run regedit.exe (or your preferred method of launching the registry editor)
- Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\batfile\shell
- Right-click on shell -> New -> Key
- Name the key "run_in_wt"
- Right-click on run_in_wt -> New -> String Value
- Name the property "MUIVerb"
- Double-click MUIVerb and set the Value data to "Run in Windows Terminal" (or however you want it to appear in the right-click menu)
- Right-click on run_in_wt again -> New -> Key
- Name the key "command"
- Double-click on the (Default) property and set the Value Data to wt new-tab --title "CMD Shell" cmd.exe /k "%1"
- The /k switch keeps the shell from exiting after the script is complete. This differs from the "normal" double-click-on-a-bat behavior. If you want the old behavior, just change the /k to /c and the shell will exit when the script is complete.
- Quoting the "%1" here is what allows us to run scripts with spaces in the path. Windows substitutes the full path of the script being right-click for the %1.
- Test it out
Testasin virtuaalilla, niin pelaa kyllä:
Edit:
Preview versiossa tuon sitten taitaa saada suoraan oletukseksi.
Get Windows Terminal Preview - Microsoft Store
- Open Windows Terminal Preview.
- Click the downward-facing chevron (⌄) on the title bar then click Settings (Ctrl + ,).
- From the Default terminal application dropdown, choose Windows Terminal Preview and click Save.
Tuo tosin taitaa vaatia, että kymppi on myös preview channelista. EIköhän tuo jossain vaiheessa tulee stableenkin.