[error 2147942402 (0x80070002) when launching `Get-Content'] with new-tab #22094

Closed
opened 2026-01-31 08:03:14 +00:00 by claunia · 2 comments
Owner

Originally created by @NikkyAI on GitHub (Aug 14, 2024).

Windows Terminal version

1.20.11781.0

Windows build number

10.0.22631.3880

Other Software

No response

Steps to reproduce

trying to open a file and watch it with Get-Content -Path file -Wait in a seperate tab

# setting up a file to watch wait Get-Content
mkdir test
echo "line" >> test/file.txt

# just to demo that Get-Content works
Get-Content -Path "test\file.txt"

# but this does not
wt new-tab -p "Windows Powershell" -d "test" Get-Content -Path "file.txt" -Wait

Expected Behavior

I expect a new tab to open that runs the specified command, eg. watch the file

Actual Behavior

first tab:

PS C:\Users\nikky> mkdir test


    Directory: C:\Users\nikky


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/14/2024   8:34 PM                test
PS C:\Users\nikky> echo "line" >> test/file.txt
PS C:\Users\nikky> Get-Content -Path "test\file.txt"
line
PS C:\Users\nikky> wt new-tab -p "Windows Powershell" -d "test" Get-Content -Path "file.txt" -Wait

second: tab:

[error 2147942402 (0x80070002) when launching `Get-Content -Path file.txt -Wait']

absolute paths do not fix it, the example is just simplified to make it reproducible on more systems

this works when just opening a new tab in the location and running the command normally
i am not sure if it failes to find the commandlet or something else is broken

other commands that invoke binaries seem to work without issues

Originally created by @NikkyAI on GitHub (Aug 14, 2024). ### Windows Terminal version 1.20.11781.0 ### Windows build number 10.0.22631.3880 ### Other Software _No response_ ### Steps to reproduce trying to open a file and watch it with `Get-Content -Path file -Wait` in a seperate tab ``` # setting up a file to watch wait Get-Content mkdir test echo "line" >> test/file.txt # just to demo that Get-Content works Get-Content -Path "test\file.txt" # but this does not wt new-tab -p "Windows Powershell" -d "test" Get-Content -Path "file.txt" -Wait ``` ### Expected Behavior I expect a new tab to open that runs the specified command, eg. watch the file ### Actual Behavior first tab: ``` PS C:\Users\nikky> mkdir test Directory: C:\Users\nikky Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 8/14/2024 8:34 PM test PS C:\Users\nikky> echo "line" >> test/file.txt PS C:\Users\nikky> Get-Content -Path "test\file.txt" line PS C:\Users\nikky> wt new-tab -p "Windows Powershell" -d "test" Get-Content -Path "file.txt" -Wait ``` second: tab: ``` [error 2147942402 (0x80070002) when launching `Get-Content -Path file.txt -Wait'] ``` absolute paths do not fix it, the example is just simplified to make it reproducible on more systems this works when just opening a new tab in the location and running the command normally i am not sure if it failes to find the commandlet or something else is broken other commands that invoke binaries seem to work without issues
claunia added the Needs-TriageIssue-BugNeeds-Author-FeedbackNo-Recent-Activity labels 2026-01-31 08:03:14 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Aug 19, 2024):

get-content isn't an executable. It's a PowerShell cmdlet. It's not something that can get launched directly with CreateProcess.

You'll probably want instead one of the following:

  1. Use the default profile to run powershell.exe
    wt new-tab -d "test" -- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -c Get-Content -Path "file.txt" -Wait
    
  2. Like the above, but manually use the Windows Powershell profile
    wt new-tab -p "Windows Powershell" -d "test" -- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -c Get-Content -Path "file.txt" -Wait
    
  3. Use the Windows Powershell profile, and append the given commandline to the commandline of the profile:
    wt new-tab -p "Windows Powershell" -d "test" --appendCommandLine -c Get-Content -Path "file.txt" -Wait
    

Does that work for you/?

@zadjii-msft commented on GitHub (Aug 19, 2024): `get-content` isn't an executable. It's a PowerShell cmdlet. It's not something that can get launched directly with `CreateProcess`. You'll probably want instead one of the following: 1. Use the default profile to run `powershell.exe` ``` wt new-tab -d "test" -- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -c Get-Content -Path "file.txt" -Wait ``` 2. Like the above, but manually use the `Windows Powershell` profile ``` wt new-tab -p "Windows Powershell" -d "test" -- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -c Get-Content -Path "file.txt" -Wait ``` 3. Use the `Windows Powershell` profile, and _append_ the given commandline to the commandline of the profile: ``` wt new-tab -p "Windows Powershell" -d "test" --appendCommandLine -c Get-Content -Path "file.txt" -Wait ``` Does that work for you/?
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Aug 23, 2024):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@microsoft-github-policy-service[bot] commented on GitHub (Aug 23, 2024): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**. <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22094