PowerShell/PowerShell

Configurable behavior on critical error: message on Error stream or pop-up dialog

sba923 opened this issue · 5 comments

Summary of the new feature / enhancement

When critical errors such as "cannot start EXE due to missing DLL" occur in File Explorer or CMD, an explanatory error dialog is displayed:

image

When the same kind of error occurs in PowerShell, no error message is displayed, only $LASTEXITCODE is set:

image

It would be desirable to make this behavior configurable, so that especially in interactive scenarios the user is supplied with information about what's happening.

This inspired by MKS Korn Shell's set -X option (@BrucePay will remember...):

From set KornShell flags and positional parameters:

image

Of course, that exception handler is not desirable for scripted / unattended execution, so it should be off by default.

It doesn't have to be a GUI-based one, outputting the explanatory text to the Error stream would also be fine.

@corbob has collected repro steps on various shells.

Proposed technical implementation details (optional)

No response

Thanks for opening the issue @sba923. I've created a simple repro and have verified behaviour in Windows PowerShell 2 on Windows 7, Windows PowerShell 5.1, and PowerShell 7.2. I have also checked the behaviour of cmd, the run dialog box, and git-bash.

To expand on what is listed in above: PowerShell behaves the same as cmd and the run dialog when you use Start-Process. In all other cases I tested (running adb, . adb, & adb) the error is not emitted outside of $LASTEXITCODE. In git-bash an error is emitted, but it is not extremely helpful as it just indicates it couldn't load a file and gives a different exit code:

image

The repro steps I've used (from an administrative PowerShell window):

choco install adb
Remove-Item "$env:ChocolateyInstall\lib\adb\tools\platform-tools\AdbWinApi.dll"
adb

Note Chocolatey is not the only way to get adb installed, but it is a pretty quick and painless way to do it.

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Is there any solution for the required "pop up window" when running .exe files missing .dll files?

#17060

@daxian-dbw I'm confused. I don't see a solution for that. Could you please give a look?

sba923 commented

This should be reopened if you ask me 😜@StevenBucher98 @SteveL-MSFT