Default to pwsh.exe then powershell.exe for cli app profiles #13278

Closed
opened 2026-01-31 03:38:30 +00:00 by claunia · 3 comments
Owner

Originally created by @WSLUser on GitHub (Apr 1, 2021).

Description of the new feature/enhancement

If you create a custom profile for running a cli app such as the SSH profile, default to using pwsh.exe for running that cli app. If it's not installed, then default to powershell.exe.

Proposed technical implementation details (optional)

Looks like cli apps such as SSH are registered to CMD automatically by WIndows Terminal. So change this to powershell.exe instead and add logic to prioritize use of pwsh.exe if installed before attempting to use powershell.exe.

An aside: I notice defining powershell.exe in the commandline parameter works as expected. However setting pwsh.exe does not. It opens a tab and immediately closes and in the brief second it's open, you can notice an error about not recognizing ssh even though in a normal pwsh tab, ssh works just fine (you might need to flash the tab a few times to get enough of the error to read it, or better yet, use some screen recording software to capture it and simply review the recording). So likely there's some env var issues there on WT side (PS7 is at top of env vars with SSH right below it).

Originally created by @WSLUser on GitHub (Apr 1, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> If you create a custom profile for running a cli app such as the SSH profile, default to using pwsh.exe for running that cli app. If it's not installed, then default to powershell.exe. # Proposed technical implementation details (optional) Looks like cli apps such as SSH are registered to CMD automatically by WIndows Terminal. So change this to powershell.exe instead and add logic to prioritize use of pwsh.exe if installed before attempting to use powershell.exe. <!-- A clear and concise description of what you want to happen. --> An aside: I notice defining powershell.exe in the commandline parameter works as expected. However setting pwsh.exe does not. It opens a tab and immediately closes and in the brief second it's open, you can notice an error about not recognizing ssh even though in a normal pwsh tab, ssh works just fine (you might need to flash the tab a few times to get enough of the error to read it, or better yet, use some screen recording software to capture it and simply review the recording). So likely there's some env var issues there on WT side (PS7 is at top of env vars with SSH right below it).
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 03:38:30 +00:00
Author
Owner

@DHowett commented on GitHub (Apr 1, 2021):

Terminal does not launch CLI applications using another shell; it launches them directly using CreateProcess. I do not think that we should add powershell's start-up time to the start-up process for every profile; it would waste time and confer no benefit.

@DHowett commented on GitHub (Apr 1, 2021): Terminal does not launch CLI applications using another shell; it launches them directly using CreateProcess. I do not think that we should add powershell's start-up time to the start-up process for every profile; it would waste time and confer no benefit.
Author
Owner

@DHowett commented on GitHub (Apr 1, 2021):

You can tell this by looking at Process Explorer -- the spawned CLI application has no parent process other than WindowsTerminal.exe. 😄

@DHowett commented on GitHub (Apr 1, 2021): You can tell this by looking at Process Explorer -- the spawned CLI application has no parent process other than WindowsTerminal.exe. :smile:
Author
Owner

@DHowett commented on GitHub (Apr 1, 2021):

An aside: I notice defining powershell.exe in the commandline parameter works as expected. However setting pwsh.exe does not. It opens a tab and immediately closes and in the brief second it's open, you can notice an error about not recognizing ssh even though in a normal pwsh tab, ssh works just fine (you might need to flash the tab a few times to get enough of the error to read it, or better yet, use some screen recording software to capture it and simply review the recording). So likely there's some env var issues there on WT side (PS7 is at top of env vars with SSH right below it).

I would guess that you are using a 32-bit version of pwsh. If you leave 'closeOnExit' set to its default setting, you will get to see the error message.

@DHowett commented on GitHub (Apr 1, 2021): > An aside: I notice defining powershell.exe in the commandline parameter works as expected. However setting pwsh.exe does not. It opens a tab and immediately closes and in the brief second it's open, you can notice an error about not recognizing ssh even though in a normal pwsh tab, ssh works just fine (you might need to flash the tab a few times to get enough of the error to read it, or better yet, use some screen recording software to capture it and simply review the recording). So likely there's some env var issues there on WT side (PS7 is at top of env vars with SSH right below it). I would guess that you are using a 32-bit version of pwsh. If you leave 'closeOnExit' set to its default setting, you will get to see the error message.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13278