[Question] How to send command line to the console of a profile #20577

Closed
opened 2026-01-31 07:18:09 +00:00 by claunia · 5 comments
Owner

Originally created by @htcfreek on GitHub (Sep 29, 2023).

Description of the new feature/enhancement

How can I start WT with a specified profile and send arguments to the console of this profile (e.g. use Powershell profile and ping host).

I tired wt.exe new-tab -p "Powershell" -c "Get-Services" which results in an error message:

[Fehler 2147942402 (0x80070002) beim Start von `{Get-Services}']

xref: https://learn.microsoft.com/de-de/windows/terminal/command-line-arguments?tabs=windows#passing-an-argument-to-the-default-shell

Proposed technical implementation details (optional)

Originally created by @htcfreek on GitHub (Sep 29, 2023). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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 How can I start WT with a specified profile and send arguments to the console of this profile (e.g. use Powershell profile and ping host). I tired `wt.exe new-tab -p "Powershell" -c "Get-Services"` which results in an error message: ``` [Fehler 2147942402 (0x80070002) beim Start von `{Get-Services}'] ``` xref: https://learn.microsoft.com/de-de/windows/terminal/command-line-arguments?tabs=windows#passing-an-argument-to-the-default-shell # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@htcfreek commented on GitHub (Sep 29, 2023):

@zadjii-msft
Is the problem I described a bug or simply not implemented?

@htcfreek commented on GitHub (Sep 29, 2023): @zadjii-msft Is the problem I described a bug or simply not implemented?
Author
Owner

@zadjii-msft commented on GitHub (Sep 29, 2023):

Oh, I think you're just doing it wrong here. I suspect what you're trying to do is the --appendCommandline thing, from #5528 / #15822.

When you call wt -p "PowerShell" -c Get-Services, wt treats -c Get-Services as the command parameter, and replaces your PowerShell profile's commandline with that. And CreateProcess("-c Get-Services",...) clearly doesn't work 😝

So, you'll either want

  • wt -p PowerShell -- {path to powershell} -c Get-Services
  • wt -p PowerShell --appendCommandline -- -c Get-Services (starting in v1.19)
@zadjii-msft commented on GitHub (Sep 29, 2023): Oh, I think you're just doing it wrong here. I _suspect_ what you're trying to do is the `--appendCommandline` thing, from #5528 / #15822. When you call `wt -p "PowerShell" -c Get-Services`, `wt` treats `-c Get-Services` as the `command` parameter, and _replaces_ your PowerShell profile's `commandline` with that. And `CreateProcess("-c Get-Services",...)` clearly doesn't work 😝 So, you'll either want * `wt -p PowerShell -- {path to powershell} -c Get-Services` * `wt -p PowerShell --appendCommandline -- -c Get-Services` (starting in v1.19)
Author
Owner

@htcfreek commented on GitHub (Sep 29, 2023):

So, you'll either want wt -p PowerShell -- {path to powershell} -c Get-Services

@zadjii-msft
Does {path to powershell} respect the path variable? Or do I need to specify the full path?

@htcfreek commented on GitHub (Sep 29, 2023): > So, you'll either want `wt -p PowerShell -- {path to powershell} -c Get-Services` @zadjii-msft Does `{path to powershell}` respect the path variable? Or do I need to specify the full path?
Author
Owner

@zadjii-msft commented on GitHub (Sep 29, 2023):

Typically, yes, it'll respect the PATH. If you're just doing simple scripting, that's usually fine, though, BEST PRACTICE would be to specify the full path.

@zadjii-msft commented on GitHub (Sep 29, 2023): Typically, yes, it'll respect the `PATH`. If you're just doing simple scripting, that's usually fine, though, BEST PRACTICE would be to specify the full path.
Author
Owner

@htcfreek commented on GitHub (Oct 2, 2023):

@zadjii-msft
Thank you for your help. I think this is what I need.
Unfortunately I can't test the v1.19 command line because wt.exe entered in run dialog brings me an access denied error.

@htcfreek commented on GitHub (Oct 2, 2023): @zadjii-msft Thank you for your help. I think this is what I need. Unfortunately I can't test the v1.19 command line because `wt.exe` entered in run dialog brings me an `access denied` error.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20577