3 Windows development-box provisioning scripts.
5 `setup-windows.bat` takes a fresh Windows install to a working C++ / native
6 development environment: editors and shells, Python, the Visual Studio
7 toolchain (including the Clang and Windows XP targeting toolsets), the Windows
8 Driver Kit, Rust (rustup, with the stable MSVC toolchain for the host as the
9 default), Android Studio and a per-user Android SDK, Android's `adb`, and a
10 handful of analysis tools (Sysinternals, OpenCppCoverage, BinSkim, the Windows
11 Performance Toolkit). It also sets the box up to be driven remotely: OpenSSH
12 Server plus an rsync build for Windows, which is what makes a throwaway VM
13 reachable from a Linux host.
15 **Nothing happens until you have seen the plan.** It first lists every step it
16 can take on this machine and lets you choose which ones to run — see
17 [Choosing what runs](#choosing-what-runs).
19 Runs on **x64 and on ARM64** (Windows 11 on Arm), and installs *different things*
20 on each: x64 is the full workstation, ARM64 a lean build box with a single
22 [Running on ARM64](#running-on-arm64) for what differs and why.
28 | `setup-windows.bat` | Entry point. Shows the plan and lets you choose, then runs the winget installs, launches the elevated half and prints its log, then runs the non-elevated script. |
29 | `setup-windows-plan.ps1` | The plan. Run by the batch file before anything else: lists every step for this machine, grouped and numbered, and takes your choice. Run it on its own with `-WhatIf` to preview; add `-HostArch ARM64 -Elevation NOLUA` to preview another kind of box. |
30 | `setup-windows-steps.ps1` | The catalog the other four read: every step's name, what it does, and where it cannot run and why. Defines functions only; it is dot-sourced, never run. |
31 | `setup-windows-current.ps1` | Asked by the batch file before the Claude Code, NASM and Android Studio installs: is what is on the box already current? Those are the installs that would otherwise run in full every time — see [Re-running](#re-running). |
32 | `setup-windows-no-uac.ps1` | The non-elevated, per-user half: WinMerge, BinSkim and upstream LLVM on the user `PATH` (x64 only), the global git config (identity, plus `core.sshCommand`), the native `ninja` pinned ahead of the one Visual Studio bundles, and an architecture audit of everything provisioned. Can also be run directly from an ordinary prompt; it lists its steps and asks first. |
33 | `setup-windows-with-uac.ps1` | The elevated half, started via UAC by the batch file. Enables `ssh-agent`, installs the OpenSSH Client and Server capabilities and starts `sshd`, unpacks the `rsync-windows` release zip for this architecture (`rsync.exe` plus the `ssh.exe` it runs) into `C:\Tools\rsync` on the machine `PATH`, then installs Visual Studio Community with the required components, the WDK, and the Windows Performance Toolkit, and reports whether Intel VTune Profiler is present. Can also be run directly from an Administrator prompt; it lists its steps and asks first. |
34 | `setup-windows-7-test-env.bat` | Prepares a **Windows 7 VM** as a test target driven from the host by `VBoxManage guestcontrol`. Copy it into the guest and run it there; it is idempotent, so re-run it after any snapshot restore. The per-user half needs no UAC (crash-dialog suppression, no screen blanking, a staging directory, the shared folder on `Z:`); the machine-wide half is skipped with a notice unless run elevated inside the guest. It then reports what the box can actually test: DWM composition, printers, audio capture devices. |
38 1. **Edit `setup-windows-no-uac.ps1` first.** The global git identity near the
39 top of the file is empty:
42 $GitUserName = '' # e.g. 'Ada Lovelace'
43 $GitUserEmail = '' # e.g. 'ada@example.com'
46 Fill in your own name and email, or leave them empty to keep your identity
47 per-repository - the script skips `user.name` / `user.email` rather than
48 writing a placeholder, and says so. Everything else in that script is set
51 2. Run it from a normal (non-elevated) prompt:
57 Before doing anything it prints the plan — every step it can take on this
58 machine, grouped and numbered — and waits:
61 Setup plan - nothing has been done yet
62 host: x64 - the full workstation
63 elevation: not elevated; expect a UAC prompt partway through, for the elevated half
65 U Per-user installs (winget, except Claude Code)
66 [x] 1 ClaudeCode Claude Code, native installer: irm https://claude.ai/install.ps1 | iex
67 [x] 2 Brave Brave.Brave
69 E Elevated setup (setup-windows-with-uac.ps1) - one UAC prompt, runs in its own window
70 [x] 25 OpenSshClient OpenSSH Client capability (ssh.exe, and the libcrypto.dll rsync's ssh.exe needs)
72 [x] 29 VisualStudio Visual Studio 2022 Community, C++: MSVC for x86/x64 + ARM64, SDK 26100 (several GB)
75 44 of 44 steps selected.
77 Enter runs the selected steps. To change them, type step numbers or ranges
78 (3 5-7), step names, or a group letter (U M E C) to switch them on or off;
79 'all' or 'none' for everything; 'q' to quit without doing anything.
82 Press Enter to run everything marked `[x]`, or switch steps off and on first;
83 the list is redrawn after each change. Steps that cannot run on this machine
84 are shown as `[-]` with the reason and have no number.
86 After Enter it runs unattended apart from a single UAC prompt for the
87 elevated half — none at all if you switched every elevated step off. Accept
88 it; declining leaves Visual Studio and the WDK uninstalled, and the script
91 3. Restart your shell afterwards so the updated user `PATH` is picked up, and
92 reboot if a step reported that a restart was required.
96 Arguments to `setup-windows.bat` set the starting point of the plan; you can
97 still adjust it before pressing Enter unless you also pass `-Yes`.
101 | `setup-windows.bat -WhatIf` | Show the plan for this machine and stop. Nothing is changed. |
102 | `setup-windows.bat -Skip VirtualBox,Brave` | Start with those switched off. |
103 | `setup-windows.bat -Only E` | Start with only the elevated half. |
104 | `setup-windows.bat -Yes` | Do not ask: run the plan as it stands. For unattended runs. |
105 | `setup-windows.bat /?` | Usage. |
107 - Steps are named as the plan shows them, comma-separated. A group letter works
108 anywhere a name does: `U` per-user installs, `M` machine-wide installs and the
109 WiX pin, `E` the elevated half, `C` per-user configuration and Pillow. A name
110 it does not recognise stops the run before anything happens — a mistyped
111 `-Skip` that was quietly ignored would install exactly what you meant to leave
113 - **With no console to ask on** — piped, scheduled, a non-interactive `ssh`
114 command — it prints the plan and stops with exit code 2 unless given `-Yes`.
115 It never assumes yes.
116 - The two halves take `-Only`, `-Skip` and `-Yes` too, and when run on their own
117 print their part of the plan and ask before doing anything, e.g.
118 `.\setup-windows-with-uac.ps1 -Only VisualStudio,Wdk`. From the batch file
119 they are handed exactly what the plan left selected, with `-Yes`, since you
120 were asked already. With nothing selected for a half it is not started — so
121 no UAC prompt is raised for an elevated half with no steps.
122 - Every step is declared once, in `setup-windows-steps.ps1`: its name, what it
123 does, and — with the reason — whether it is x64-only (`-X64Only`) or needs an
124 administrator (`-Admin`). The planner, the batch file and both halves read
125 that one list and check each other: a step the list does not know is refused
126 rather than run, and a selected step that nothing implements fails the run
127 rather than quietly not happening. Adding a step means a row there plus the
128 code that does it, gated on the same name.
129 - Some steps build on others — the WiX pin needs the .NET SDK, the Clang and XP
130 toolsets need Visual Studio. The plan notes it when you switch the
131 prerequisite off, but does not stop you: it may well be installed already.
135 Every step checks before it acts, so running `setup-windows.bat` again on a
136 provisioned box installs only what is missing or has a newer version out.
137 Nothing is reinstalled at the version it already has. Where a check cannot
138 decide — no network, a version string it does not recognise — it installs as
139 before rather than skipping: a failed check must never be why something is left
140 missing or out of date.
142 | step | how it decides |
144 | winget packages | `winget install` on a package winget can see is installed upgrades it when a newer version exists and otherwise does nothing — winget's own default. `--force`, which would install regardless, is never used. |
145 | `ClaudeCode` | Anthropic's installer always downloads and reinstalls, so `setup-windows-current.ps1` asks first: is `%USERPROFILE%\.local\bin\claude.exe` the latest release — the version the installer's own endpoint names — and the build for this host? Only both skip it. |
146 | `NASM` | Its per-user fallback install registers nothing, so winget cannot see it and would rerun the installer every time. `setup-windows-current.ps1` compares that `nasm.exe` with the version winget offers. A machine-wide NASM is left to winget. |
147 | `Rustup` | Needs no help: rustup registers itself under the manifest's product code and rewrites its version when it updates itself, so winget sees what is really there. |
148 | `AndroidStudio` | Installed only when it is missing. Studio updates itself in the app, and winget's package is marked never to upgrade it; the check keeps winget from installing over a Studio it cannot match to its package, as on a box where Studio was installed some other way. |
149 | `WiX` | Skipped when 5.0.2 is already in the .NET global tool store. |
150 | `OpenSshClient`, `OpenSshServer` | Installed only when the capability is not. |
151 | `Rsync` | The release's `.sha256` is fetched first and compared with the hash recorded when the files were installed (`rsync-windows.sha256`). The zip is downloaded only when they differ or a file is missing. |
152 | `VisualStudio`, `VsClang`, `VsWinXP` | `vswhere -requires` says whether the install already has every component of a pass. A pass with nothing to add does not run the installer, and with nothing to add anywhere the bootstrapper is not even downloaded. The script never updates Visual Studio itself; the Visual Studio Installer does that. |
153 | `Wdk`, `Wpt` | Skipped when the kit, or the toolkit, is already there. |
154 | `BinSkim` | Asks NuGet for the newest stable version before downloading a package well over 100 MB; `nupkg-version.txt` beside the tool records what is installed. |
155 | `RustToolchain` | `rustup toolchain install` updates stable when there is a newer one and otherwise reports it unchanged. |
156 | `AndroidSdk` | The command-line tools are re-downloaded only when Google's package index has a newer revision than the installed one; `android sdk install` updates the platform, build-tools and platform-tools only when they are out of date. A re-run with nothing new takes seconds. |
157 | `Pillow` | `pip install` leaves an installed Pillow alone. It does not upgrade it either. |
158 | the rest | Configuration: `PATH` entries are added only when missing, and settings are written with the values they already have. |
162 - The elevated half writes a transcript to `setup-windows-uac.log` next to the
163 script; the batch file prints it when the elevated window closes. The log is
164 gitignored, as it contains local paths.
165 - **git uses a Win32-OpenSSH client.** `setup-windows-no-uac.ps1` sets
166 `core.sshCommand`. Git for Windows otherwise prefers its own bundled MSYS2
167 `ssh.exe`, which cannot reach the Windows `ssh-agent` service that the elevated
168 half enables - Win32-OpenSSH publishes the agent on a named pipe the MSYS2
169 build does not speak. Without this, keys loaded with `ssh-add` from PowerShell
170 are invisible to `git`, and a push falls back to hunting for a key file and
171 prompting for its passphrase. The value uses forward slashes on purpose: git
172 parses `core.sshCommand` with shell quoting rules, in which a backslash is an
174 - **Which `ssh.exe` git gets.** `C:\Tools\rsync\ssh.exe` — the fast build the
175 elevated half unpacks — if it is there, `%WINDIR%/System32/OpenSSH/ssh.exe`
176 otherwise. It is the same client with the same `~/.ssh`, agent and
177 `known_hosts`; the difference is the stdin pump, and without it anything git
178 *pushes* is capped at ~17 MB/s. Candidates are tried by **running** them
179 (`ssh -V`), not by `Test-Path`: the fast build needs a `libcrypto.dll` that an
180 image without the OpenSSH Client capability does not have, and a client that
181 will not start should be found here rather than on the next `git push`.
182 This is also why `setup-windows.bat` now runs the elevated half **first** — the
183 fast `ssh.exe` has to exist before the git config step can prefer it. The
184 non-elevated half still runs even when the elevated one failed; it just falls
185 back. Re-run `setup-windows-no-uac.ps1` on its own at any time to re-pick.
186 - All the scripts are safe to re-run: nothing is reinstalled at the version it
187 already has. See [Re-running](#re-running) for how each step decides.
188 - `setup-windows-no-uac.ps1` runs its steps independently: one failing warns and
189 the rest still run, and it exits 1 if any did. The `.bat` reports that and
190 carries on. Use `-Only` / `-Skip` to re-run a subset, e.g.
191 `.\setup-windows-no-uac.ps1 -Skip BinSkim`.
192 Run it **non-elevated**: it writes per-user state (the `HKCU` `PATH`, the
193 `.gitconfig` under `%USERPROFILE%`), so an elevated run would configure the
194 administrator's profile instead. It warns if you do.
195 - **Remote access.** OpenSSH Server is installed from the Windows on-demand
196 capability (10/1809+), set to start automatically, and given an inbound TCP 22
197 firewall rule on *all* profiles — a VM's host-only or bridged adapter is
198 routinely classified Public, which is the usual reason a running `sshd` is
199 unreachable. Windows ships no `rsync`, so a build of it
200 ([nuket/rsync-windows](https://github.com/nuket/rsync-windows)) is installed to
201 `C:\Tools\rsync` and added to the **machine** `PATH`. That last detail matters:
202 the remote end of an `rsync` runs non-interactively, with no login shell, and
203 Win32-OpenSSH builds that environment from the registry `PATH` rather than from
204 a profile. Key auth needs `~/.ssh/authorized_keys` ACL'd to just you and
205 `SYSTEM`; accounts in the Administrators group use
206 `C:\ProgramData\ssh\administrators_authorized_keys` instead.
207 - **rsync brings its own `ssh.exe`.** That release ships as one zip per
208 architecture — `rsync-windows-x86.zip`, `-x64.zip` and `-arm64.zip`, each
209 holding `rsync.exe`, an `ssh.exe`, `COPYING.txt` and `NOTICE-ssh.txt` — and the
210 elevated half picks the zip matching the host, verifies it against the
211 published `.sha256`, unpacks the pair together, then **runs** the unpacked
212 `ssh.exe` and removes it if it will not start. Together is the point:
213 `rsync.exe` prefers an `ssh.exe` sitting in its own directory, and the release
214 builds one because the client Windows ships reads its stdin 3 KB at a time,
215 which holds a transfer *from* the box at ~17 MB/s however fast the link is.
216 Nothing else about it differs — same `~/.ssh`, same `ssh-agent`, same
217 `known_hosts` — and a bare `ssh` still resolves to the in-box client, which
218 sits ahead of `C:\Tools\rsync` on the `PATH`. It links against the
219 `libcrypto.dll` the **OpenSSH Client** capability puts in `System32` (Windows'
220 own LibreSSL, which uses AES-NI) and ships no copy of its own, so the elevated
221 half installs that capability first and falls back to `rsync.exe` alone,
222 warning, on an image that will not offer it.
223 - The `rsync` download follows the `releases/latest/download/` redirect rather
224 than the GitHub API: unauthenticated API calls are rate-limited to 60/hour per
225 IP, which a provisioning run behind a shared NAT can genuinely exhaust. To hold
226 a box on a known build, pin the tag in `$RsyncUrl`
227 (`.../releases/download/<tag>/<asset>`) instead.
228 - Visual Studio is installed in three labelled passes (base workload, Clang/LLVM,
229 XP toolset) so a failure identifies which component group is responsible. On
230 ARM64 only the first runs — the other two are skipped there, each printing why.
231 The last two are optional passes: a failure there warns and provisioning continues,
232 because neither is needed to build with MSVC and losing the whole toolchain
233 over a component you can add later from the installer UI is the worse outcome.
234 - **Which Visual Studio generation.** `$VsChannel` near the VS step picks it —
235 `17` for VS 2022, `18` for VS 2026 — and `$VsEdition` picks Community /
236 Professional / Enterprise. It is **architecture-split by default**: 17 on x64,
237 where the `v141`/XP toolset in the component list is the reason to pin a
238 generation, and 18 on ARM64, where that toolset cannot exist anyway (no
239 ARM64-hosted 14.16 compiler), so nothing holds Arm back to the older one.
240 - **The aka.ms path differs per generation** — VS 2022 is published under
241 `/release/`, VS 2026 under `/stable/`, which `$VsChannelPath` derives. This is
242 not cosmetic: `https://aka.ms/vs/18/release/vs_community.exe` is *not* a 404,
243 it silently redirects to Bing and returns **200 with an HTML body**. A wrong
244 guess there downloads a web page, names it `vs_community.exe`, and fails later
245 at `Start-Process` with something that looks nothing like a bad URL. The step
246 therefore checks the downloaded file starts with an `MZ` header and throws with
247 the URL if it does not.
248 - `Get-VsInstallPath` scopes its `vswhere` query to that generation
249 (`-version "[17.0,18.0)"`). That scoping is load-bearing: a bare
250 `vswhere -products *` returns **every** Visual Studio on the box, newest
251 first, and on a machine that already has VS 2026 the old unscoped lookup handed
252 an 18.x install path to a 17.x bootstrapper as `modify --installPath`, so every
253 pass targeted the wrong product. The step now also lists any other generations
254 it found and states that it left them alone — when none of them matches
255 `$VsChannel` the script is about to fetch a second, largely redundant
256 toolchain, and that should be a visible decision. On ARM64, where `$VsChannel`
257 is 18, an existing VS 2026 **is** the match and gets modified in place rather
259 - **Windows Performance Analyzer is not part of Visual Studio.** VS has its own
260 Performance Profiler, which is a different, `.diagsession`-based tool and
261 cannot open an `.etl`. WPA ships with `xperf` and `wpr` in the Windows
262 Performance Toolkit, which exists in exactly two places: as an optional
263 *feature* of the Windows SDK (`OptionId.WindowsPerformanceToolkit`) and inside
264 the Windows ADK, which bundles the same toolkit. Whether the SDK install that
265 Visual Studio performs selects that feature varies by version, so the elevated
266 half **detects first** — `%ProgramFiles(x86)%\Windows Kits\10\Windows
267 Performance Toolkit`, its 64-bit twin, and the ADK location — and only falls
268 back to `winget install Microsoft.WindowsADK` when nothing is there. It then
269 re-asserts that directory on the machine `PATH` (the toolkit's own installer
270 usually does this, and the Start Menu gets *Windows Kits > Windows Performance
271 Toolkit* shortcuts for WPA and WPR). To install just the toolkit instead of the
272 whole ADK, run the standalone SDK setup with
273 `winsdksetup.exe /features OptionId.WindowsPerformanceToolkit /q`. A newer WPA
274 also exists in the Microsoft Store (`winget install --id 9N0W1B2BXGNZ --source
275 msstore`); it is not installed here because the Store source needs an
276 interactive, signed-in session, which the unattended elevated half does not
278 - **Intel VTune Profiler is reported, not installed.** The elevated half prints
279 whether it is on the box, its version, and the path to `vtune.exe`; if it is
280 missing it prints the download page instead (and says so if the CPU is not
281 Intel). Automating the install is not worth it here: the offline installer is a
282 ~750 MB download from a URL carrying a per-release GUID with no "latest"
283 redirect behind it, so every new build would mean editing a hard-coded link,
284 and it is only worth having on Intel silicon since hardware event-based
285 sampling reads Intel PMU counters. It does install unattended if you want it
289 intel-vtune-<version>_offline.exe -a --silent --cli --eula accept
292 **Run it from an administrator account, elevated.** Hardware event-based
293 sampling (`uarch-exploration`, `memory-access`, `hotspots -knob
294 sampling-mode=hw`) requires it, and VTune warns about that at the top of every
295 unelevated run. Worth knowing that the failure it gives there is *"cannot
296 recognize the processor"*, which reads like a hardware problem and is not one:
297 the drivers (`sepdrv5`, `sepdal`, `vtss`) are installed and running, and VTune
298 identifies the PMU through them. There is no group to join to get around it —
299 the Linux driver can be handed to a `vtune` group, but on Windows the
300 documented answer is to run as administrator.
302 - **Collect traces from an elevated Administrator session. Non-elevated
303 collection was tried here and abandoned.** The attempt was to put one ordinary
304 account into `BUILTIN\Performance Log Users`, which appears in the default
305 security descriptors ETW keeps per provider GUID under
306 `HKLM\SYSTEM\CurrentControlSet\Control\WMI\Security`, and collect without a UAC
307 prompt. It does not survive contact with the real workflow: `xperf -on base`
308 and `wpr -start` drive the *NT Kernel Logger*, reserved for Administrators and
309 LocalSystem, and granting the group `SeSystemProfilePrivilege` ("Profile system
310 performance") plus an explicit ACE for `TRACELOG_ACCESS_KERNEL_LOGGER` on
311 `SystemTraceControlGuid` — all three in place, across a reboot — still answered
314 xperf: error: NT Kernel Logger: Access is denied. (0x5).
317 It is not a check an ACE overrides, and the same wall turned up often enough
318 elsewhere that the whole approach was dropped rather than carried as a
319 half-working path. **Sign in to an administrator account and run `xperf`, `wpr`
320 and VTune from an elevated prompt.** Analysis is the exception and never needed
321 any of this: `wpa.exe` opens an existing `.etl` as a plain user.
323 If an earlier revision of these scripts ran on a box, it left that account in
324 the group. Take it back out with:
327 net localgroup "Performance Log Users" DOMAIN\user /delete
330 Two revisions also granted the privilege and the ACE. Undo the privilege in
331 `secpol.msc` > Local Policies > User Rights Assignment > "Profile system
332 performance" by removing Performance Log Users. The ACEs sit in the
333 `{9e814aad-3204-11d2-9a82-006008a86939}` value under
334 `HKLM\SYSTEM\CurrentControlSet\Control\WMI\Security`: strip the `LU` entries
335 from that descriptor rather than deleting the value, which also carries entries
336 for SYSTEM, Administrators and two service accounts.
338 - **Claude Code is not installed through winget.** Recent releases of
339 `Anthropic.ClaudeCode` are broken through that route, so the batch file runs
340 Anthropic's own installer, `irm https://claude.ai/install.ps1 | iex`: it
341 checks the download against the release manifest's SHA-256 and puts `claude`
342 in `%USERPROFILE%\.local\bin`, per-user. Two things are fixed up around it.
343 The script picks its ARM64 or x64 build from `$env:PROCESSOR_ARCHITECTURE`
344 alone, which reads `AMD64` in an emulated x64 shell on ARM64 (see
345 [Detecting the architecture](#detecting-the-architecture)), so the batch file
346 sets that variable from the registry's answer for the installer's process.
347 And the script refuses a 32-bit PowerShell, which is what `powershell` is from a
348 32-bit `cmd.exe`, so it is run through `%SystemRoot%\Sysnative` when that
349 exists. A copy left over from the winget route can shadow the new one on the
350 `PATH`; the step warns if it finds one (`winget uninstall
351 Anthropic.ClaudeCode` removes it), and the architecture audit shows which
353 - **Rust.** winget installs rustup (`Rustlang.Rustup`, per-user, under
354 `%USERPROFILE%\.cargo` and `.rustup`). Its silent install is
355 `rustup-init -y -q`, which already sets up a stable toolchain for whatever
356 host rustup detects. The `RustToolchain` step in `setup-windows-no-uac.ps1`
357 then pins the answer: `stable-x86_64-pc-windows-msvc` on x64,
358 `stable-aarch64-pc-windows-msvc` on ARM64, installed, made the default, and set
359 as rustup's default host. That matters on ARM64, where an x64 rustup —
360 an older install, or one started from an emulated shell — would otherwise
361 quietly set up an emulated compiler. The `-msvc` toolchains link with the
362 Visual Studio the elevated half installs, but only need it to *build*:
363 installing rustup first is fine, and with `-y` rustup-init just warns that
364 the prerequisites are missing rather than installing a Visual Studio of its
365 own. Re-running the step updates stable. It also resets the default to
366 stable, so leave `RustToolchain` out of the plan if you have chosen another
367 default on purpose. The architecture audit reports the compiler *inside* the
368 toolchain: `.cargo\bin\rustc.exe` is a rustup proxy, so its architecture is
369 rustup's, not the compiler's.
370 - **`adb` and `fastboot`** come from `Google.PlatformTools`, a portable zip that
371 winget unpacks under `%LOCALAPPDATA%\Microsoft\WinGet\Packages` and puts on the
372 user `PATH` (`adb.exe` needs the `AdbWinApi` DLLs beside it). The manifest
373 calls it x64, but every binary in it is 32-bit **x86** — checked on r37.0.1 —
374 and there is no ARM64 build. It runs under WOW64 on x64 and under x86
375 emulation on ARM64, which every Windows on Arm has; the audit lists it as
376 expected. It stays on ARM64 for the same reason `iperf3` does: it is bound by
377 the link to the device, not by the CPU.
378 - **Android Studio and the Android SDK** are separate steps. Studio
379 (`Google.AndroidStudio`) is machine-wide — its installer elevates itself — and
380 is installed only when missing, since it updates itself. The SDK is per-user,
381 in Studio's default `%LOCALAPPDATA%\Android\Sdk` (or wherever `ANDROID_HOME`
382 already points): the command-line tools, platform-tools, and the newest
383 stable platform and build-tools from Google's package index, read at run
384 time. That is what Studio's first-run wizard would set up, and it is enough
385 to build: Gradle fetches whatever else a project asks for. The step sets
386 `ANDROID_HOME`, puts the command-line tools on the user `PATH`, and points
387 `JAVA_HOME` at Studio's bundled JDK for a command-line `gradlew` when there is
388 no `JAVA_HOME` already. The SDK licences are accepted on your behalf — the
389 plan says so before anything runs. Both are x64-only: Studio has no ARM64
390 build, and the SDK's Windows build tools are x86/x64. Three things about
391 the current command-line tools (23.0), found when this step was written:
392 - `sdkmanager` is deprecated. It is now a shim over the new **Android CLI**
393 (`android.exe`), which on first use installs itself into
394 `%USERPROFILE%\.android` — about 90 MB in `bin\`, and a `cli\` folder with
395 its own Java runtime. It also keeps a spool of **usage metrics** there and
396 uploads them; no opt-out was found. The step calls the CLI directly.
397 - **CLI 1.0.16406183 crashes on the way out of every `sdk` command**
398 (`0xC0000409`) on this Windows 10, after the work is done. So the step does
399 not trust its exit code: each package must be present afterwards, and a
400 crash with everything in place is printed as a note, not a failure.
401 - Windows PowerShell 5.1's progress bar made the 148 MB command-line tools
402 download take about ten minutes; with it off, the whole first install took
403 under a minute. The BinSkim download now skips the progress bar for the
405 - The scripts were extracted from a native Windows project, so the component
406 selection is tuned for that: Spectre-mitigated runtimes, the v141/XP toolset,
407 and driver-kit headers. Trim the component lists in the `.ps1` if you don't
408 need them — each group is a plain array near the top.
412 All three scripts detect the host architecture and adapt. Nothing needs a flag —
413 run `setup-windows.bat` exactly as on x64.
415 **The two architectures deliberately install different things.** x64 is the full
416 workstation; ARM64 is provisioned as a lean build box with a single C/C++
418 [ARM64 installs less, on purpose](#arm64-installs-less-on-purpose) below for the
419 list and the reasoning.
421 ### Detecting the architecture
423 All three scripts read the **machine-level registry value**, not the environment
424 and not `RuntimeInformation.OSArchitecture`. Both of those report the *emulated*
425 architecture inside an emulated x64 process — which is what you get by launching
426 `powershell` or `cmd` from an x64 shell (Git Bash, for one) on an ARM64 box.
427 Measured on this machine, from that emulated shell:
431 | `[RuntimeInformation]::OSArchitecture` | `X64` ✗ |
432 | `%PROCESSOR_ARCHITECTURE%` | `AMD64` ✗ |
433 | `HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment` | `ARM64` ✓ |
435 `OSArchitecture` is documented as the *OS's* architecture, and on .NET Core it
436 is; under .NET Framework on Prism it is not. It is kept only as a fallback. This
437 used to be a cosmetic mislabel in a log line — now that the architecture decides
438 which packages are installed at all, reading it wrong provisions the wrong
441 > The batch file calls `reg.exe` by full path and parses it **without** piping to
442 > `find`/`findstr`. Both are shadowable by anything earlier on the `PATH`, and a
443 > POSIX `find` turns the whole detection into a silent no-op that leaves the
444 > emulated answer standing. That is not hypothetical; it is how this was found.
446 **The build toolchain is fully native.** Visual Studio's ARM64 installer and MSVC
447 are ARM64 binaries, and MSVC cross-compiles every target from an ARM64 host with
448 no emulation in the compiler:
451 cmake -B build -A ARM64 && cmake --build build --config Release :: native
452 cmake -B build -A x64 && cmake --build build --config Release :: cross
453 cmake -B build -A Win32 && cmake --build build --config Release :: cross
456 **ARM64 uses Visual Studio 2026** (`$VsChannel = 18`) while x64 stays on VS 2022.
457 Nothing forces that split — the Arm box simply has no reason to stay on the older
458 generation, since the `v141`/XP toolset that pins x64 there cannot run on Arm at
459 all — so Arm takes the newer MSVC. Note this is a *default*, not a limitation:
460 VS 2026 does still offer `v141` and `WinXP` as components on x64.
462 The base component group now names `VC.Tools.x86.x64` **and** `VC.Tools.ARM64`
463 explicitly instead of relying on `--includeRecommended`, which resolves
464 differently per host: on an ARM64 machine the workload's recommended set is the
465 ARM64-targeting toolchain, and the x64 cross-compiler is *not* implied. Spectre
466 runtimes and ATL are likewise requested for both target families
467 (`VC.ATL.ARM64.Spectre` is a separate component from `VC.ATL.Spectre`).
469 ### ARM64 installs less, on purpose
471 The ARM64 machine here is a constrained VM, and nearly everything it was
472 installing without a native build was going to run under Prism emulation anyway.
473 The exceptions were individually defensible and collectively a VM full of x64
474 binaries. So the split is now explicit: **ARM64 gets MSVC and nothing that
475 duplicates it or that exists only as an x64 binary.**
477 | dropped on ARM64 | where | why |
479 | `Brave.Brave` | `setup-windows.bat` | no ARM64 build; an emulated browser is the slowest thing on the box, and Edge is in-box and native |
480 | `WinMerge.WinMerge` | `setup-windows.bat` | ARM64 ships as a **machine-scope** installer only, so an unelevated `winget` can install nothing but the emulated x64 build |
481 | `LLVM.LLVM` | `setup-windows.bat` | second Clang, dropped along with VS's `clang-cl` |
482 | `NASM.NASM` | `setup-windows.bat` | x86/x86-64 assembler with no ARM64 target; MSVC's `armasm64.exe` is the native one |
483 | `Google.AndroidGPUInspector` | `setup-windows.bat` | x64-only, and it profiles Android devices rather than anything compiled here |
484 | `OpenCppCoverage` | `setup-windows.bat` | collects coverage by stepping x86/x64 instructions, so it cannot instrument an ARM64 binary at all |
485 | VS Clang/LLVM component | `setup-windows-with-uac.ps1` | see below |
486 | Windows Driver Kit | `setup-windows-with-uac.ps1` | see below |
487 | BinSkim | `setup-windows-no-uac.ps1` | the NuGet package publishes `win-x64` only |
488 | Android Studio (`Google.AndroidStudio`) | `setup-windows.bat` | Google publishes no Windows ARM64 build |
489 | Android SDK | `setup-windows-no-uac.ps1` | its Windows build tools are x86/x64 only, as is Android Studio |
491 x64 keeps every one of them. The decision is made in one place,
492 `setup-windows-steps.ps1` (`-X64Only`, with the reason): the plan shows each as
493 `[-]` with that reason, and the run log repeats it where the step would have
494 run, rather than leaving a silent gap.
496 **`clang-cl` is dropped by choice, not by limitation.** A native ARM64 `clang-cl`
497 *is* offered on Arm and did work here before the split. Two things establish
498 that: the `VC.Llvm.Clang` VSIX is `productArch=neutral` with no `chip` or
499 `machineArch` restriction, so the Arm installer offers it; and MSVC's
500 `VC\Tools\Llvm` tree is partitioned by **host** architecture, with real ARM64
501 binaries in `ARM64\bin`, which is where `clang-cl.exe` lands:
505 | `VC\Tools\Llvm\bin` | x86 |
506 | `VC\Tools\Llvm\x64\bin` | x64 |
507 | `VC\Tools\Llvm\ARM64\bin` | ARM64 |
509 > Watch for a false positive when checking by hand: `VC\Tools\Llvm\*\bin` holds
510 > `clang-format.exe` and `clang-tidy.exe` on **any** host, installed or not —
511 > those ship with the NativeDesktop workload. Their presence does not mean the
512 > compiler is there; look for `clang-cl.exe`.
514 Note that the VS installer never uninstalls a component you simply stopped
515 asking for, so a box provisioned before this split keeps its `clang-cl` until it
516 is explicitly removed. The verification step says so and prints the
519 **The WDK is dropped for two reasons, and the second one bites on x64 too.** The
520 ARM64 box builds user-mode software, so it does not need a driver kit — but this
521 particular WDK *cannot* install here regardless. The kit requires the **matching
522 Windows SDK revision**, and revisions are not side-by-side: `Include\10.0.26100.0`
523 is one directory, whichever revision wrote it. VS 2026 installs SDK
524 **26100.7705**; `linkid=2335869` is WDK **26100.6584**, the kit paired with VS
525 2022. `wdksetup.exe /quiet` therefore aborts:
528 WDK installer exit code: 15605
529 WER: WDK / 10.1.26100.6584 / Install / 0x80070642
532 `0x642` is `1602`, `ERROR_INSTALL_USEREXIT` — a silent install cancelling itself
533 on a failed prerequisite check. Nothing to do with Arm or emulation; the same
534 pairing fails on x64. If a driver ever does need building against VS 2026, use
535 the kit Microsoft's [supported WDK downloads](https://learn.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads)
536 table pairs with it — the 28000.x one — not this link. x64 with VS 2022 has the
537 matched pair, so it installs there.
539 **Compiler diversity now lives on the x64 box**, which has room for three
540 toolchains: MSVC, VS's `clang-cl`, and **upstream LLVM** (`winget install
541 LLVM.LLVM`). Upstream runs on its own schedule, is usually several major versions
542 ahead of the Clang VS bundles, and installs to `C:\Program Files\LLVM` rather
543 than inside the VS tree, so the two are genuinely independent. Two Clang majors
544 plus MSVC over the same sources is what catches the bugs a single toolchain
545 agrees with itself about. Watch the `PATH` there: a bare `clang-cl` may resolve
546 to upstream while CMake's `-T ClangCL` keeps using VS's, so pass a full
547 `-DCMAKE_CXX_COMPILER` when it matters.
549 **Rust is on both boxes, and native on ARM64.** It is a different language
550 rather than a second C/C++ compiler, so it does not bend the one-compiler rule,
551 and its `-msvc` toolchain links through MSVC's own `link.exe`. The ARM64 box
552 gets `stable-aarch64-pc-windows-msvc`; to build x64 Rust code from there, add
553 the x64 *target* (`rustup target add x86_64-pc-windows-msvc`) rather than an x64
554 host toolchain, which would run emulated.
556 What you end up with on ARM64:
560 | **Native ARM64** | Git, Python, .NET SDK, PowerShell, VS Code, Windows Terminal, Sysinternals, Claude Code, CMake, Ninja, the VS installer, **MSVC**, MSBuild, the SDK tools (`rc`, `signtool`), rustup and **Rust** (`stable-aarch64-pc-windows-msvc`), the in-box OpenSSH client, and the Windows Performance Toolkit. |
561 | **Emulated** | `iperf3` (x64; network-bound), `adb` and `fastboot` (x86 — Google ships no other Windows build; bound by the USB/TCP link to the device), and the ADK *installer* (x64; the toolkit it lays down is native). |
562 | **Emulated, minor** | `py.exe` (python.org ships the launcher shim as x86; it execs the native `python.exe`) and `vswhere.exe` (Microsoft ships x86 only; runs once). |
563 | **Not installed** | Brave, WinMerge, upstream LLVM, NASM, Android GPU Inspector, OpenCppCoverage, BinSkim, VS `clang-cl`, the WDK, and the Android SDK — see the table above. |
564 | **Unavailable** | VirtualBox, the Windows 7 x86 test VM, Intel VTune, Android Studio, and the `v141` / Windows XP targeting toolset. |
566 ### The architecture audit
568 `setup-windows-no-uac.ps1` ends with an **`ArchAudit`** step that reads the PE
569 COFF header of every tool the box provisions and reports what you would actually
570 run, resolved PATH-first. It reads the file itself rather than trusting package
571 metadata — a multi-architecture package (Sysinternals) ships every build in one
572 zip under different names, and an installer's metadata says nothing about which
573 binary landed. Purely informational; it never fails the run. Skip it with
576 Anything emulated with a listed reason prints as expected. Anything emulated
577 *without* one is called out, with a remedy where a native build exists — which is
578 how the `ninja` problem below was found.
580 ### Elevation, and the case where there is no prompt
582 `setup-windows.bat` works out **once, at the top**, whether this account can
583 elevate, and reports it as `Elevation: ALREADY | PROMPT | NOLUA`:
587 | `ALREADY` | Already elevated. The elevated half runs **directly** — no point asking to elevate what already is. |
588 | `PROMPT` | Not elevated, UAC on. Elevation is requested: an administrator gets a consent prompt, a standard user gets an over-the-shoulder **credential** prompt. |
589 | `NOLUA` | UAC is off machine-wide (`EnableLUA = 0`) **and** this is not an administrator. Elevation is *impossible*, not merely declined. |
591 `IsInRole(Administrator)` is false for an admin running unelevated under UAC,
592 which is what makes `ALREADY` mean *actually elevated* rather than *could be*.
594 **Why `NOLUA` needs detecting rather than attempting.** `Start-Process -Verb
595 RunAs` is not honest about it. With UAC disabled the `RunAs` verb is **silently
596 ignored**: no prompt appears, the child starts with the caller's own unelevated
597 token, and `Start-Process` reports **exit code 0** as though it had worked. The
598 elevated script then refuses itself on its `#Requires -RunAsAdministrator` line,
599 exits 1, and never reaches its `Start-Transcript` — so there is no log either.
600 Read naively that is indistinguishable from a cancelled UAC prompt, which is
601 exactly what this script used to report, sending you to look for a prompt that
602 could never have appeared.
604 Measured on such a box: `Start-Process -Verb RunAs` returned exit 0 while the
605 child reported itself as the *unelevated* calling user.
607 **What is skipped when elevation is impossible.** The elevated half, plus four
608 packages that sit in the "per-user" section but are machine-wide installers.
609 They used to fail on every run with opaque codes — `exit 5`
610 (`ERROR_ACCESS_DENIED`) for the .NET SDK, MSI `1603` for CMake and Android GPU
611 Inspector, `exit 1` for OpenCppCoverage, whose installer self-elevates. They are
612 now shown as unavailable in the plan, with the reason, and skipped with one
613 clear line each. None blocks a build: the .NET SDK is
614 only there for the WiX MSI tooling, CMake also ships inside Visual Studio, AGI
615 profiles Android devices, and OpenCppCoverage cannot instrument ARM64 binaries
618 A `NOLUA` run is a **success** (exit 0), not a failure — the per-user half did
619 its job. To finish the box, run it from an administrator account, then re-run
620 `setup-windows-no-uac.ps1` as yourself so the per-user `PATH` and `.gitconfig`
621 land in *your* profile rather than the administrator's.
623 Two consequences worth knowing rather than rediscovering:
625 - **LLVM does not fail — it relocates.** Its NSIS installer targets
626 `%ProgramFiles%\LLVM`, and when it cannot write there it silently falls back to
627 a per-user directory (observed: `%USERPROFILE%\Documents\LLVM`) while winget
628 still reports *Successfully installed*. The compiler is genuinely there and
629 native; nothing can find it. The `LlvmPath` step looks in that fallback, puts
630 the directory on the user `PATH`, and says so.
631 - **WinMerge silently downgrades to x64.** Upstream publishes ARM64 as a
632 **machine-scope** installer and x64 as a **per-user** one, so an unelevated
633 winget lets its scope preference beat its architecture preference. The batch
634 now asks for `--architecture arm64` first and falls back, so an admin run gets
635 the native build and a standard-user run still gets a working one.
637 ### Two gotchas the audit surfaces
639 - **Visual Studio bundles an x64 `ninja.exe` even on ARM64.** It matters more
640 than a one-off tool would, because ninja is re-invoked for every edge in the
641 build graph — it is the one place emulation is paid over and over rather than
642 once. `winget install Ninja-build.Ninja` gets the native `ninja-winarm64`
643 build, and the `NinjaPath` step pins its directory to the **front** of the user
644 `PATH`. VS's bundled `cmake.exe` *is* ARM64, so only ninja has this problem.
646 On which copy wins inside a Developer Command Prompt: the native one. VS adds
647 its ninja from `Common7\Tools\vsdevcmd\ext\cmake.bat`, which does
648 `set "PATH=%PATH%;...\CMake\bin;...\CMake\Ninja"` — an **append**, so the VS
649 directories land at the very end of the composed `PATH`, behind every machine
650 and user entry. A native ninja anywhere on the user `PATH` already beats it,
651 measured on an ARM64 box. The `NinjaPath` step is therefore insurance rather
652 than the load-bearing fix: winget *appends* its package directory to the user
653 `PATH`, so without it the margin rests on two append orders staying as they
654 are, one of them in a file Microsoft owns and revises.
655 - **Sysinternals ships every architecture in one zip**, and the ARM64 build is
656 not the default-named exe. `ProcessExplorer.zip` contains `procexp.exe` (x86),
657 `procexp64.exe` (x64) and `procexp64a.exe` (**ARM64**) — so run the `*64a.exe`
658 variants; plain `procexp.exe` runs emulated. (`Microsoft.Sysinternals.Suite`
659 has a dedicated `SysinternalsSuite-ARM64.zip` if you prefer the whole set.)
661 - **x64 emulation is checked, not assumed.** Everything in the "emulated" row
662 needs Prism, which is present on Windows 11 on Arm but absent on Windows 10 on
663 Arm (x86-only there) and on some Server images. The elevated half tests for
664 `System32\xtajit64.dll` up front and warns, rather than letting the failure
665 surface much later as a binary that will not start.
666 - **VirtualBox is skipped.** There is no ARM64 Windows host build, and the x64
667 one cannot be rescued by emulation: a hypervisor is kernel-mode, and its x64
668 driver will not load on an ARM64 kernel. This is also what makes
669 `setup-windows-7-test-env.bat` unreachable from an ARM64 host — it prepares a
670 Windows 7 *x86* guest, which neither VirtualBox nor Hyper-V on ARM64 can run.
671 (That script itself is unchanged; it runs inside the guest, so it never sees
672 the host architecture.)
673 - **The `v141` / Windows XP toolset is skipped**, and the verification step says
674 `n/a` instead of warning about it. The components are still *listed* in the
675 catalog on Arm, so this is a deliberate skip rather than a hard unavailability
676 — but the 14.16 toolset predates Windows on Arm as a host and ships
677 `HostX86`/`HostX64` compilers only, so the best you could get is an
678 x86-emulated compiler, and XP targeting is not supported from an Arm host.
679 Nothing is lost that this box could have used:
680 Windows XP never ran on ARM64, so the only point of an XP-targeting build here
681 would be producing x86 binaries, which the current toolset does natively via
683 - **OpenCppCoverage is no longer installed on ARM64.** Unlike the rest of the
684 emulated row this was a real ceiling rather than a slowdown: it collects
685 coverage by debugging the process under test and stepping x86/x64
686 instructions, so it can cover cross-compiled x86/x64 binaries but **not** an
687 ARM64 one. A coverage tool that cannot cover this machine's own output belongs
688 on the x64 box, which is where it still installs. Run coverage there.
689 - **BinSkim is no longer installed on ARM64 either**, though the reason is
690 weaker: the NuGet package publishes `win-x64` only (its other RIDs are
691 `linux-x64`, `linux-arm64`, `osx-x64`), but BinSkim *reads* PE headers and load
692 configs, so its own architecture is independent of the binaries it analyses —
693 an emulated x64 BinSkim checks ARM64 binaries perfectly well. It went with the
694 rest of the x64-only set to keep the rule simple, not because it was broken.
695 The RID list is still ordered preference on x64, so a future `win-arm64` build
696 would be picked up with no further change.
697 - **`rsync` is native on ARM64 now**, and its `ssh.exe` is still verified by
698 running it. The release publishes an `arm64` asset as of `v3.5.0-gdeeda96f`;
699 both binaries in it are `0xAA64`, and the `ssh.exe` reports
700 `OpenSSH_for_Windows_10.0p2 ... LibreSSL 3.8.2` on this box.
702 Before that asset existed, ARM64 took the x64 zip. The `rsync.exe` was fine —
703 a transfer is bounded by the socket, not by emulated CPU — but its `ssh.exe`
704 links against `System32\libcrypto.dll`, which on ARM64 is an **ARM64** binary
705 an x64 process cannot load. It died with `0xC0000135`
706 (`STATUS_DLL_NOT_FOUND`) and had to be deleted on every run. That matters more
707 than it sounds: `rsync.exe` *prefers* an `ssh.exe` in its own directory, so a
708 present-but-broken one does not degrade to the in-box client — it breaks rsync
709 outright, with an error naming a dead remote shell rather than `ssh.exe`.
711 The elevated half still runs `ssh -V` after unpacking and **deletes** the
712 binary if it will not start. The check is kept because it is what found that
713 problem, and it still covers a missing or too-old `libcrypto.dll` on any
714 architecture. An x64 `rsync.exe` surviving on an ARM64 box now shows up in the
715 audit as emulation *without* a listed reason, with a remedy pointing at a
716 re-run. The `core.sshCommand` step in the non-elevated half already picked its
717 candidate by running it, and is unchanged.
718 - **Intel VTune reports `n/a`** rather than printing a download link: there is no
719 Windows-on-Arm build, and its value is reading Intel PMU counters. Use the
720 Windows Performance Toolkit (`wpr`/`xperf` to collect, `wpa` to analyse), or
721 Arm Performance Studio / Streamline for Arm PMU sampling.
722 - **NASM is not installed on ARM64.** It assembles x86/x86-64 only — there is no
723 ARM64 target in it and no ARM64 build of it — so it went into the x64-only set
724 with the rest. The ARM64 assembler is `armasm64.exe`, which ships with MSVC.
725 Its installer is also one of the two here that fall back to a per-user
726 directory it never registers (`%LOCALAPPDATA%\bin\NASM`), so `winget uninstall`
727 cannot find it afterwards; the `Uninstall.exe` in that directory is the way out.
728 - **`vswhere` stays under the 32-bit Program Files** on ARM64 too
729 (`%ProgramFiles(x86)%\Microsoft Visual Studio\Installer`), so that path is
730 unchanged. The VS Installer is x86-registered there by contract even though the
731 installer binaries themselves are native.
732 - **The WDK registry probe reads both hives.** `wdksetup.exe` is 32-bit and
733 writes under `WOW6432Node` on x64, but which hive a kit lands in has varied
734 across versions and architectures, and reading only one made an installed WDK
735 look absent — costing a needless multi-GB reinstall on every run.