Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error 0x800700c1 when launching pwsh.exe #11717

Closed
kkostrzewa-coupa opened this issue Nov 9, 2021 · 10 comments · Fixed by #12086
Closed

error 0x800700c1 when launching pwsh.exe #11717

kkostrzewa-coupa opened this issue Nov 9, 2021 · 10 comments · Fixed by #12086
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@kkostrzewa-coupa
Copy link

Windows Terminal version (or Windows build number)

1.11.2921.0

Other Software

pwsh.exe 7.2.0

Steps to reproduce

my terminal has C:\Users\Kevin Kostrzewa\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe in the Powershell profile (note the space between Kevin and *Kostrzewa()

Installing Visual Studio 2022 created a file called c:\users\Kevin to be created, containing some installation logs.

Terminal failed to launch pwsh.exe after, presumably because of the space in the terminal profile around powershell. I think this is related to #7195

Expected Behavior

pwsh.exe to launch

NOTE: I think Terminal could be more resilient around pathing and launching the .exe so a file can't be injected ahead of it with clever space filled pathing. This may be a security issue, if c:\users\Kevin was attempted to be CreateProcess'ed.

Actual Behavior

[error 0x800700c1 when launching `C:\Users\Kevin Kostrzewa\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe']

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Nov 9, 2021
@kkostrzewa-coupa
Copy link
Author

I fixed this on my machine by killing the bad c:\users\Kevin file, so I'm not facing this issue right now.

@zadjii-msft
Copy link
Member

Could you clarify- the commandline

C:\Users\Kevin Kostrzewa\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe

did you set that as the commandline in your profile, or are you using one of the dynamically generated pwsh.exe profiles that the Terminal creates for you?

[error 0x800700c1 when launching C:\Users\Kevin Kostrzewa\AppData\Local\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe']`

I suspect that implies that the Terminal did know that the exe was at that full path, but CreateProcess still decided to use C:\Users\Kevin as the executable path. Hmmm.

@kkostrzewa-coupa
Copy link
Author

The command line was dynamically generated by Terminal

@elsaco
Copy link

elsaco commented Nov 9, 2021

@kkostrzewa-coupa did you install PS7 manually? When adding PS7 from Microsoft Store this is what's being automatically inserted in settings.json

            {
                "guid": "{5fb123f1-af88-5b5c-8953-d14a8def1978}",
                "hidden": false,
                "name": "PowerShell 7",
                "source": "Windows.Terminal.PowershellCore"
            }

Tested on Win10 & WT Preview 1.12.2931.0

@DHowett
Copy link
Member

DHowett commented Nov 9, 2021

Interestingly, this is the same as what happens when you have a file called C:\Program and we try to launch something out of C:\Program Files...

@kkostrzewa-coupa
Copy link
Author

kkostrzewa-coupa commented Nov 9, 2021

@elsaco I believe I installed from the Microsoft store. Regardless, I think the core issue (weirdness around space in path) is still a problem.

@malxau
Copy link
Contributor

malxau commented Nov 10, 2021

CreateProcess, when given a string that doesn't contain quotes indicating the executable, is documented to probe and guess where the executable really is: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa

Applications are supposed to use quotes so CreateProcess doesn't guess, partly because if it does guess it's possibly a vulnerability. It'd actually be nice to be able to globally disable this guessing behavior to preemptively flush out this class of bug.

@kkostrzewa-coupa
Copy link
Author

@malxau from my read of that doc, the guessing occurs when lpApplicationName is NULL. Can lpApplicationName be set to the string in the Terminal Command Line?

@zadjii-msft
Copy link
Member

I'd suspect no, since people could have a commandline like wsl -d Ubuntu, where wsl should be the application name.

Presumably though, there's a way we could construct the commandline for the powershell profiles such that they'd be resistant to that. Maybe just wrapping them up in another layer of quotes?

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. labels Nov 11, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Nov 11, 2021
@zadjii-msft zadjii-msft added this to the Terminal v2.0 milestone Nov 11, 2021
@ghost ghost added the In-PR This issue has a related PR label Jan 4, 2022
@zadjii-msft zadjii-msft modified the milestones: Terminal v2.0, 22H2 Jan 4, 2022
@ghost ghost closed this as completed in #12086 Jan 4, 2022
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Jan 4, 2022
ghost pushed a commit that referenced this issue Jan 4, 2022
Ensures the PowerShell Core profile's commandline is quoted. This allows
the profile to work correctly if there are files in place on the machine
(e.g. one called `C:\Program`) that prevent `CreateProcess()` from
invoking the un-quoted commandline.

## Validation Steps Performed
Created a file called `C:\Program` and opened the PowerShell profile in
terminal.

Closes #11717
DHowett pushed a commit that referenced this issue Jan 21, 2022
Ensures the PowerShell Core profile's commandline is quoted. This allows
the profile to work correctly if there are files in place on the machine
(e.g. one called `C:\Program`) that prevent `CreateProcess()` from
invoking the un-quoted commandline.

## Validation Steps Performed
Created a file called `C:\Program` and opened the PowerShell profile in
terminal.

Closes #11717

(cherry picked from commit 4930508)
@ghost
Copy link

ghost commented Feb 3, 2022

🎉This issue was addressed in #12086, which has now been successfully released as Windows Terminal Preview v1.13.10336.0.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants