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 possible to have these open in the new Windows Terminal by default when I run them? No, I don't want to open the terminal, navigate to the script, and run it. I just want to click on the .bat and have it run in the CMD window that is within the Windows Terminal app.
Can this be done?
I tried finding the terminal exe so that I could set ps1 files to open with it but I get an error when I try to do that. See screenshot.
Thanks!
Best Answer
I am putting this here since it is too short for a comment, and that you are not asking a PowerShell code question/issue, but asking a 'How do I configure my environment/chosen tool, to do X or Y.
... whatever processors you have configured in your WT settings.
Even if you reghack this, it will still only run the default shell/command processor you have configured in the JSON settings. So, why start a shell host, just to run a shell/command processor.
What
NotTheDr01ds
is showing, is already the default when right-clicking a .ps1 file and trying to change that to WT.exe will not work as you'd think.You can first prove this to yourself by using WinKey + R and typing in the below. One will not work the other will.
So, any reg hack would require you to specify the command processor and the filename and any arguments needed for a successful run. As noted in my comments. You can avoid reghacks and just create a shortcut and add this shortcut to your SendTo menu. In Windows Explorer, just type...
Or in PowerShell just to this:
... and paste your shortcut there (I have lots there), then you have to make the settings changes.
I am letting you know in advance, that this ran into some issues.
Sometimes it worked, sometimes it did not.
Now, of course, if you wanted to do this for any of the command processors, then you need to create multiple shortcuts, alter them as needed, and paste them to the SendTo folder, then right-click your file, and select the proper SendTo shortcut.