Skip to content

Desktop on Windows: read a No at the approval prompt as Windows actually gives it - #2793

Merged
davidmckayv merged 2 commits into
mainfrom
fix/windows-runas-cancel
Dec 2, 2026
Merged

davidmckayv merged 2 commits into
mainfrom
fix/windows-runas-cancel

Conversation

@davidmckayv

@davidmckayv davidmckayv commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Docker Desktop update: the update went on to open Docker's own installer, and a second approval prompt came up about 20 seconds later. The "Your approval is needed" card with Try again never showed.
  • WSL fix: the window said "That didn't finish" for a No.

Why: both elevation scripts used Start-Process -Verb RunAs, and #2715 told a No by the Win32 code ERROR_CANCELLED (1223) somewhere in the error. On that computer a No makes Start-Process throw an InvalidOperationException (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.Start with the runas verb (UseShellExecute), the call Start-Process wraps. It throws the Win32Exception itself, with NativeErrorCode 1223 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.

  • On Windows, saying No to Windows' approval prompt during the Docker Desktop update or the Windows Subsystem for Linux fix is now read as a No everywhere: OpenBot waits for Try again, without opening Docker's installer or saying the step didn't finish.

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_it and the_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 with left: Some(1), right: Some(1223), as the e2e saw. With the fix they feed the new scripts the No as Process.Start gives it (a Win32Exception with ERROR_CANCELLED, no inner exception, thrown from a .NET method as Process.Start throws it), and pass.
  • the_elevated_install_runs_the_installer_and_hands_back_its_exit_code and the_elevated_launcher_runs_the_fix_and_hands_back_its_exit_code: the real scripts on real Windows, with Start-Process replaced by its failing No so any use of it would show. The runner's Windows doesn't ask, so cmd /c exit 7 and the WSL launcher's exit 5 run 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.

…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.
…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.
@davidmckayv
davidmckayv added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit d5ec54f Dec 2, 2026
38 checks passed
@davidmckayv
davidmckayv deleted the fix/windows-runas-cancel branch December 2, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant