Repository navigation
Desktop on Windows: read a No at the approval prompt as Windows actually gives it - #2793
Merged
Merged
Conversation
…s says it, is a No On Windows Server 2022 (PowerShell 5.1) a No makes Start-Process -Verb RunAs throw an InvalidOperationException with no inner exception and no Win32 code. These run the Docker update's and the WSL fix's elevation scripts in real PowerShell with that answer, and expect ERROR_CANCELLED (1223). They fail on this commit: both scripts exit 1.
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 2, 2026 14:36
…carries ERROR_CANCELLED Start-Process -Verb RunAs wraps the Win32Exception a No raises in an InvalidOperationException with no inner exception, so on Windows Server 2022 the Docker update's and the WSL fix's elevation scripts exited 1 for a No: the update opened Docker's installer and Windows asked a second time, and the WSL fix said it hadn't finished. Both now raise the prompt through .NET's Process.Start with the runas verb, which throws the Win32Exception itself, ERROR_CANCELLED (1223) on a No, so the scripts exit 1223 whatever Windows' language. The installer's arguments travel in an environment variable, quoted as Windows reads a command line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a real Windows computer (Windows Server 2022, PowerShell 5.1, a second local admin so Windows asks), saying No to Windows' approval prompt was not read as a No:
Why: both elevation scripts used
Start-Process -Verb RunAs, and #2715 told a No by the Win32 codeERROR_CANCELLED(1223) somewhere in the error. On that computer a No makesStart-Processthrow anInvalidOperationException(HResult 0x80131509) with no inner exception and no Win32 code, so the scripts exited 1. The only thing left that says "cancelled" is the message, which is in Windows' own language.Fix: both scripts now raise the prompt through .NET's
Process.Startwith therunasverb (UseShellExecute), the callStart-Processwraps. It throws theWin32Exceptionitself, withNativeErrorCode1223 on a No, so the scripts exit 1223 whatever the language. Any other failure still exits 1 and shows what went wrong. The installer's arguments travel in an environment variable, quoted as Windows reads a command line.Changelog
OpenBot Desktop.
Tests (Windows-only tests run in real Windows PowerShell on CI's Windows job):
the_elevated_install_script_exits_1223_on_a_no_as_windows_says_itandthe_elevated_launcher_exits_1223_on_a_no_as_windows_says_it: on this PR's first commit they fed the old scripts the No exactly as Windows Server 2022 gave it (InvalidOperationException, no inner exception) and failed on CI's Windows job withleft: Some(1), right: Some(1223), as the e2e saw. With the fix they feed the new scripts the No asProcess.Startgives it (aWin32ExceptionwithERROR_CANCELLED, no inner exception, thrown from a .NET method asProcess.Startthrows it), and pass.the_elevated_install_runs_the_installer_and_hands_back_its_exit_codeandthe_elevated_launcher_runs_the_fix_and_hands_back_its_exit_code: the real scripts on real Windows, withStart-Processreplaced by its failing No so any use of it would show. The runner's Windows doesn't ask, socmd /c exit 7and the WSL launcher'sexit 5run elevated and their codes come back. A missing installer is a failure, not a No.a_command_line_reads_back_as_the_arguments_it_was_made_from: the installer's command line, quoted as Windows reads it.