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

Opening a tab for PowerShell Core fails with 0x800700c1 #7195

Closed
DigiBanks99 opened this issue Aug 6, 2020 · 18 comments
Closed

Opening a tab for PowerShell Core fails with 0x800700c1 #7195

DigiBanks99 opened this issue Aug 6, 2020 · 18 comments
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@DigiBanks99
Copy link

DigiBanks99 commented Aug 6, 2020

Environment

Windows build number: 10.0.19041.0
Windows Terminal version (if applicable): 1.1.2021.0

Any other software:
- Visual Studio Community 2019 - 16.7
- Visual Studio Code - 1.47.3
- Cmder - 180626

Steps to reproduce

  1. Reset settings.json to defaults.json.
  2. Open the PowerShell tab. Note: Not Windows PowerShell.

Expected behavior

The PowerShell Core terminal is opened without reporting an error or at least gives a more descriptive and useful error message.

Actual behavior

Receive the following error: [error 0x800700c1 when launching 'C:\Program Files\PowerShell\7\pwsh.exe']

image

@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 Aug 6, 2020
@KalleOlaviNiemitalo
Copy link

0x800700c1 is HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT), "%1 is not a valid Win32 application."

Giving "a more descriptive and useful error message" is #7186. However, ERROR_BAD_EXE_FORMAT seems a bit of a special case because the error message contains "%1". Possible ways to implement:

  • Recognize ERROR_BAD_EXE_FORMAT and display a custom message, instead of calling FormatMessage.
  • Recognize ERROR_BAD_EXE_FORMAT and replace "%1" with the path.
  • Always replace "%1" with the path, no matter what the error code is. But what to do if there is "%2" as well?
  • Display the "%1" as is.

I wonder what caused the error in the first place. IIRC, ERROR_BAD_EXE_FORMAT is usually caused by trying to run a 64-bit program on a 32-bit system, but that seems unlikely here because the PowerShell installer should have failed in that case. Are you able to run C:\Program Files\PowerShell\7\pwsh.exe if you don't use Windows Terminal?

@DigiBanks99
Copy link
Author

DigiBanks99 commented Aug 7, 2020

Yes, I can start up PowerShell Core by using Win+R and pasting C:\Program Files\PowerShell\7\pwsh.exe.

Typing pwsh in any prompt also opens the terminal successfully.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Aug 7, 2020
@DHowett
Copy link
Member

DHowett commented Aug 13, 2020

This is wild! And if you run pwsh.exe from cmd.exe inside windows terminal, does it work?

Just to confirm: other profiles work fine, right?

@DHowett DHowett added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Aug 13, 2020
@DigiBanks99
Copy link
Author

DigiBanks99 commented Aug 13, 2020

Yes, it starts up fine from cmd.exe or Windows PowerShell from within the terminal. I'm getting the same issue with Azure Cloud Shell:

[error 0x800700c1 when launching 'C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.1.2021.0_x64__8wekyb3d8bbwe\TerminalAzBridge.exe']

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Aug 13, 2020
@zadjii-msft
Copy link
Member

@DigiBanks99 how did you install the Terminal? The Store, winget, choco, scoop, something else? And what architecture is your PC?

Also how did you install powershell 7?

@zadjii-msft zadjii-msft added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Aug 19, 2020
@DigiBanks99
Copy link
Author

I installed both the Terminal from the Windows Store and I installed PowerShell 7 via the PowerShell-7.0.3-win-x64.msi downloaded from the GitHub release page.

My CPU architecture is x64. I'm using Windows 10 Home on version 2004.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Aug 21, 2020
@dc-rose
Copy link

dc-rose commented Sep 11, 2020

I have exactly the same issue in most respects, the error reported is exactly the same and I can open in all the ways described with the same results. I am not sure if this is relevant but the install was a bit odd. I had powershell preview installed from store (7.1.0-preview.6) it told me that there was an update available and then I updated it via powershell, but I can't remember or find the blog post that it came from and rather than updating preview it installed another powershell 7.0.3 (not exactly an update and not the preview version) but my fault for not understanding the command I was entering. So Windows Terminal was already installed some time ago was working fine and then out of the blue I open another powershell tab and the error described happens and yes I can open it all the other ways but windows terminal is dead to powershell. Any help apreciated.

@DigiBanks99
Copy link
Author

Any news?

@KalleOlaviNiemitalo
Copy link

Two Process Monitor traces of pwsh.exe being run by Windows Terminal and by cmd.exe might help track down the cause, more so than tracing through CreateProcess with a debugger. Such traces would contain personal information though, e.g. in values of environment variables, so perhaps you'd better compare them yourself than post them in public. The following Process Monitor filter might be suitable:

Column Relation Value Action
Process Name is WindowsTerminal.exe Include
Process Name is pwsh.exe Include
Process Name is TerminalAzBridge.exe Include
Event Class is Process Include
Event Class is Profiling Exclude

@DHowett
Copy link
Member

DHowett commented Oct 23, 2020

Marking this as feedback for the procmon trace. Thanks @KalleOlaviNiemitalo

@DHowett DHowett added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Oct 23, 2020
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Oct 27, 2020
@ghost
Copy link

ghost commented Oct 27, 2020

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.

@DigiBanks99
Copy link
Author

I'm not sure I understand what you are asking me to do?

@ghost ghost added the Needs-Attention The core contributors need to come back around and look at this ASAP. label Oct 27, 2020
@ghost ghost removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Oct 27, 2020
@zadjii-msft
Copy link
Member

@KalleOlaviNiemitalo Could you help walk @DigiBanks99 through the process of grabbing a procmon race? I'm not as familiar with procmon so I'm not totally sure how to do it myself 😆

@Lyt99
Copy link

Lyt99 commented Nov 2, 2020

I just encountered the same problem with 1.3.2651.0, and I found a file named 'Program' in my C:\, which seemed to be executed instead of pwsh.exe, then I deleted it and it works fine now.
I tested with creating an executable file C:\Program.exe, and it has been run by terminal
this should be an issue when execute a file with path containing space

@DigiBanks99
Copy link
Author

Thank you! This was exactly my problem. I wonder what put that file there in the first place? Having deleted the C:\Program file fixed my issue. 😊

@LucaSkywalkerZA
Copy link

Wtf is this "Program" File??? Thanks this fixed the problem for me too.

@AymericG
Copy link

AymericG commented May 24, 2021

Same, I deleted the C:\Program file and it solved my problem.

@Robert-lintun
Copy link

I just encountered the same problem with 1.3.2651.0, and I found a file named 'Program' in my C:, which seemed to be executed instead of pwsh.exe, then I deleted it and it works fine now.
I tested with creating an executable file C:\Program.exe, and it has been run by terminal
this should be an issue when execute a file with path containing space

Seriously? Thanks for the tips, it fixes my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

9 participants