This is something I have been struggling with for a few days and each time I think I have adjourned it, it falls apart.
I want to launch a new Windows Terminal window but with two caveats:
- The new terminal must be a windows terminal profile
- At the same time, pass a command line argument to the WT profile’s shell, which is pwsh, so pwsh’s
-command
parameter
A few days ago, I figured out how to send command line arguments to the profiles shell, Pass a command line argument to the new terminal window that is about to be launched? #17521.
This successfully opens a new terminal window with my_profile
profile. The host prints my message
:
wt -p my_profile pwsh -noExit -command "'my message'"
All was good and well until it broke on me today. The following does open a new terminal window but the window prints an error:
wt -p my_profile pwsh -noExit -command "'my message' ; 'my second message'"
The error is printed by windows terminal (not pwsh):
[error 2147942402 (0x80070002) when launching `" 'my second message'"']
If I eliminate WT from the equation, pwsh correctly receives input to its -command
parameter:
pwsh -noExit -command "'my message' ; 'my second message'"
#my message
#my second message
Is pwsh really not at fault here?
Is there some sort of pwsh mechanism that can help me to navigate around this issue?
I would appreciate any solutions in either pwsh or wt
Windows Terminal 1.19 preview
pwsh 7.4
win 11