]> vilimpoc.org git repositories - dotfiles/commit - setup-windows.bat
dotfiles: detect that elevation is impossible instead of misreporting it
authorMax Vilimpoc <max@vilimpoc.org>
Sat, 5 Sep 2026 23:06:42 +0000 (01:06 +0200)
committerMax Vilimpoc <max@vilimpoc.org>
Sat, 5 Sep 2026 23:06:42 +0000 (01:06 +0200)
commitcd774a195092cd0ab4c8e92862d0c5cf7e04f195
treeb0d4498e839fd0fb9ac2711cf77c9ba274f879e6
parentfbe899b67d263a1ae5404d3ed25f5f091c3d2c1e
dotfiles: detect that elevation is impossible instead of misreporting it

Running as a standard user on a box with UAC disabled produced no prompt
at all, and the script blamed a cancelled one.

The cause is that Start-Process -Verb RunAs does not report this. With
UAC off machine-wide (EnableLUA = 0) the RunAs verb is SILENTLY IGNORED:
no prompt appears, the child starts with the caller's own unelevated
token, and Start-Process returns exit code 0 as though it had worked.
Measured on the box: exit 0 from Start-Process, while the child reported
itself as the unelevated calling user. The elevated script then refuses
itself on its #Requires -RunAsAdministrator line, exits 1, and never
reaches Start-Transcript - so there is no log either. That is
indistinguishable from a declined prompt unless you know to look, which
is why the old message sent you hunting for a prompt that could never
have appeared.

So decide up front rather than trying and guessing afterwards. One check
at the top of setup-windows.bat classifies the account as ALREADY (run
the elevated half directly - asking to elevate what already is elevated
is pointless, and on a UAC-off box RunAs would be the no-op above),
PROMPT (request it, expect a consent or credential prompt), or NOLUA
(elevation is impossible; say so and skip). IsInRole(Administrator) is
false for an admin running unelevated under UAC, which is what makes
ALREADY mean actually elevated rather than merely capable.

The missing-log message now says which of the two things happened, using
that classification, rather than asserting a cancelled prompt.

Also stop running four installers that cannot succeed. The .NET SDK,
CMake, Android GPU Inspector and OpenCppCoverage sit in the "per-user"
section but are machine-wide installers, and on an account that cannot
elevate they failed on every run with codes that explain nothing - exit 5
(ERROR_ACCESS_DENIED), MSI 1603 twice, and exit 1. Grouped and skipped
with a single clear line when elevation is impossible. None of them
blocks a build: the .NET SDK is only here for the WiX MSI tooling, CMake
also ships inside Visual Studio, AGI profiles Android devices, and
OpenCppCoverage cannot instrument ARM64 binaries anyway.

A NOLUA run is now a success (exit 0) rather than a reported failure -
the per-user half did its job - and the closing ARM64 summary points at
the architecture audit for what actually landed, since that list
describes what the script provides rather than what this run achieved.

All three paths exercised: NOLUA skips and exits 0, ALREADY runs the
elevated half directly, PROMPT requests elevation and reports a declined
prompt correctly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ak6VzfGyaocrykX1LhNMwt
README.md
setup-windows.bat