]> vilimpoc.org git repositories - dotfiles/blob - setup-windows.bat
1d32adae6c50142d34c9a4067e72120ea16cec2e
[dotfiles] / setup-windows.bat
1 @echo off\r
2 \r
3 @rem ---------------------------------------------------------------------------\r
4 @rem setup-windows.bat - provision a fresh Windows box for native development\r
5 @rem ---------------------------------------------------------------------------\r
6 \r
7 @rem --- Non-admin (per-user) winget installs ---\r
8 winget install Anthropic.ClaudeCode\r
9 winget install Git.Git\r
10 winget install Microsoft.DotNet.SDK.10\r
11 winget install Microsoft.PowerShell Microsoft.Sysinternals.ProcessExplorer Microsoft.Sysinternals.ProcessMonitor Microsoft.Sysinternals.SDelete Microsoft.VisualStudioCode Microsoft.WindowsTerminal\r
12 winget install Oracle.VirtualBox\r
13 winget install Python.Python.3.13\r
14 winget install WinMerge.WinMerge\r
15 \r
16 @rem OpenCppCoverage: native (PE) line coverage for the C++ binaries. run-coverage-occ.py drives the\r
17 @rem pytest suite under it to produce an HTML report (the binaries under test build with PDBs,\r
18 @rem which it reads). The installer elevates via UAC.\r
19 winget install OpenCppCoverage.OpenCppCoverage\r
20 \r
21 @rem --- WiX 5.0.2, pinned on purpose ---\r
22 @rem WiX packages our proprietary software into MSIs, and the version is pinned to keep that\r
23 @rem free of a fee. 5.0.2 is the last release distributed under the Microsoft Reciprocal\r
24 @rem License alone. From 6.0 onward the package also carries OSMFEULA.txt, an Open Source\r
25 @rem Maintenance Fee agreement: a monthly fee owed by anyone who uses the PREBUILT BINARIES\r
26 @rem as part of revenue-generating activity and has annual gross revenue >= US$10,000.\r
27 @rem\r
28 @rem It is a fee for the binaries, not a restriction on what we ship - MS-RL is file-scoped\r
29 @rem and never reached the MSIs WiX builds, under any version - but 5.0.2 owes nothing.\r
30 @rem The 6.x/7.x SOURCE is still MS-RL too, so self-compiling is another way out; a pin is\r
31 @rem the cheaper one. This replaces `winget install WiXToolset.WiXCLI`, which has no version\r
32 @rem selector and so installs the latest (7.0.0 today, EULA and all).\r
33 @rem\r
34 @rem PIN THE MSBUILD SIDE TOO. A .wixproj referencing WixToolset.Sdk without a version\r
35 @rem resolves to the latest - 7.x, same EULA - and nothing here constrains it. Pin it in the\r
36 @rem project: <Project Sdk="WixToolset.Sdk/5.0.2">.\r
37 @rem\r
38 @rem dotnet.exe is called by full path: winget put the SDK on the machine PATH a few lines\r
39 @rem ago, but this cmd session inherited its environment before that and cannot see it.\r
40 @rem install-then-update is for re-runs - install fails once the tool is there, and update\r
41 @rem then holds it at exactly 5.0.2 - which keeps this script idempotent like the rest.\r
42 set "DOTNET_EXE=%ProgramFiles%\dotnet\dotnet.exe"\r
43 "%DOTNET_EXE%" tool install --global wix --version 5.0.2 || "%DOTNET_EXE%" tool update --global wix --version 5.0.2\r
44 \r
45 @rem Report what the pin actually produced. By full path again, and because the shim lands in\r
46 @rem a directory this session's PATH predates: expect "5.0.2+<commit>", not 7.x.\r
47 "%USERPROFILE%\.dotnet\tools\wix.exe" --version\r
48 \r
49 @rem ---------------------------------------------------------------------------\r
50 @rem No package manager needed for the Windows build\r
51 @rem\r
52 @rem Just:\r
53 @rem   cd windows && cmake -B build -G "Visual Studio 17 2022" -A x64 && cmake --build build --config Release\r
54 @rem ---------------------------------------------------------------------------\r
55 \r
56 @rem --- Elevated installs (VS2022, WDK, system tools) ---\r
57 @rem The elevated script runs in its own window and logs to setup-windows-uac.log.\r
58 @rem -PassThru + $p.ExitCode propagates its real exit code back through to ERRORLEVEL.\r
59 @rem\r
60 @rem -TraceUser passes YOU across the UAC boundary. Accepting that prompt with an\r
61 @rem administrator's credentials runs the elevated half AS that administrator, so\r
62 @rem it cannot see whose box this is; the account named here is the one it grants\r
63 @rem non-elevated ETW collection rights to (xperf / wpr without a UAC prompt).\r
64 set "UAC_LOG=%~dp0setup-windows-uac.log"\r
65 if exist "%UAC_LOG%" del "%UAC_LOG%"\r
66 \r
67 powershell -NoProfile -Command "$p = Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile','-ExecutionPolicy','Bypass','-File','""%~dp0setup-windows-with-uac.ps1""','-TraceUser','""%USERDOMAIN%\%USERNAME%""' -Wait -PassThru; exit $p.ExitCode"\r
68 set "UAC_RC=%ERRORLEVEL%"\r
69 \r
70 @rem --- Surface the elevated session's output (its window has already closed) ---\r
71 if exist "%UAC_LOG%" (\r
72     echo.\r
73     echo ===== elevated setup log ^(%UAC_LOG%^) =====\r
74     type "%UAC_LOG%"\r
75     echo ===== end of elevated setup log =====\r
76 ) else (\r
77     echo [setup-windows] WARNING: no elevated log found at "%UAC_LOG%".\r
78     echo [setup-windows] The elevated window may have been cancelled at the UAC prompt.\r
79 )\r
80 \r
81 @rem --- Non-elevated PowerShell half ---\r
82 @rem WinMerge on the user PATH, BinSkim, and the global git config (identity +\r
83 @rem core.sshCommand -> a Win32-OpenSSH client, so git shares the Windows\r
84 @rem ssh-agent). EDIT THE GIT IDENTITY at the top of setup-windows-no-uac.ps1\r
85 @rem before the first run.\r
86 @rem\r
87 @rem Deliberately NOT elevated: every step writes per-user state (the HKCU PATH,\r
88 @rem the .gitconfig under %USERPROFILE%), which the elevated half would write to\r
89 @rem the administrator profile instead.\r
90 @rem\r
91 @rem AFTER the elevated half on purpose: core.sshCommand prefers the ssh.exe that\r
92 @rem half unpacks beside rsync.exe - a push through the in-box client is capped\r
93 @rem at ~17MB/s - and it can only prefer it once it is on disk. Run either way,\r
94 @rem including when the elevated half failed above: nothing here depends on it,\r
95 @rem and the fallback is the in-box client that Windows already has.\r
96 @rem\r
97 @rem Non-fatal: these are conveniences, and the elevated half is the part worth\r
98 @rem the UAC prompt. A failure warns and provisioning continues.\r
99 powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0setup-windows-no-uac.ps1"\r
100 if not "%ERRORLEVEL%"=="0" echo [setup-windows] WARNING: setup-windows-no-uac.ps1 reported a failure ^(see above^); continuing.\r
101 \r
102 if not "%UAC_RC%"=="0" (\r
103     echo.\r
104     echo [setup-windows] ELEVATED SETUP FAILED ^(exit code %UAC_RC%^). See log above.\r
105     exit /b %UAC_RC%\r
106 )\r
107 echo.\r
108 echo [setup-windows] Elevated setup completed successfully.\r
109 \r
110 @rem Removed: this doesn't work as well as I hoped, maybe try again later\r
111 @rem -- Install Headroom ---\r
112 @rem py -m pip install "headroom-ai[all]"\r
113 @rem npm install headroom-ai\r
114 \r
115 py -m pip install Pillow