From: Max Vilimpoc Date: Fri, 28 Aug 2026 11:22:07 +0000 (+0200) Subject: dotfiles: put vswhere.exe on the user PATH X-Git-Url: https://vilimpoc.org/repos/dotfiles/commitdiff_plain/7d4887fe245e7643a497e87e04fc8f97d8ca436f?hp=aa6eb7838922a67ac1c9d7169fa0bb5b58b17762 dotfiles: put vswhere.exe on the user PATH The Visual Studio installer drops vswhere.exe in %ProgramFiles(x86)%\Microsoft Visual Studio\Installer and nothing adds that directory to the PATH, so build scripts that locate VS with it - and VsDevCmd.bat itself - print "'vswhere.exe' is not recognized" on every run. New VsWhere step in the non-elevated half; it is skipped with a warning when no VS installer is present. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01DhsGf8BtmQE1PtS1CAKns4 --- diff --git a/setup-windows-no-uac.ps1 b/setup-windows-no-uac.ps1 index f6500b8..1197300 100644 --- a/setup-windows-no-uac.ps1 +++ b/setup-windows-no-uac.ps1 @@ -12,6 +12,10 @@ What this installs / configures: - WinMerge on the user PATH + - vswhere.exe on the user PATH: the Visual Studio installer puts it in + %ProgramFiles(x86)%\Microsoft Visual Studio\Installer, which nothing adds + to the PATH, so build scripts (and VsDevCmd.bat itself) complain that + 'vswhere.exe' is not recognized - BinSkim (binary hardening analyzer) in %LOCALAPPDATA%\Programs\BinSkim, on the user PATH - Global git identity, and core.sshCommand pointed at a Win32-OpenSSH @@ -31,7 +35,7 @@ param( # for several, dot-call the script or use -Command: # .\setup-windows-no-uac.ps1 -Skip BinSkim,GitConfig # powershell -File .\setup-windows-no-uac.ps1 -Skip BinSkim - [ValidateSet('WinMerge', 'BinSkim', 'GitConfig')] + [ValidateSet('WinMerge', 'VsWhere', 'BinSkim', 'GitConfig')] [string[]] $Skip = @() ) @@ -90,6 +94,22 @@ function Add-WinMergeToUserPath { Add-ToUserPath $dir } +function Add-VsWhereToUserPath { + # vswhere.exe is how scripts locate Visual Studio (MSBuild, VsDevCmd.bat, + # the Windows SDK), and the VS installer drops it in a fixed directory that + # is never on the PATH. VsDevCmd.bat itself prints "'vswhere.exe' is not + # recognized" on every run without it. The directory is fixed by contract + # (32-bit Program Files, no version in the path), so there is nothing to + # search for: if it is missing, Visual Studio is not installed. + Write-Step 'vswhere on the user PATH' + $dir = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer' + if (-not (Test-Path (Join-Path $dir 'vswhere.exe'))) { + Write-Warning "vswhere.exe not found in $dir (no Visual Studio installer present); user PATH unchanged." + return + } + Add-ToUserPath $dir +} + function Install-BinSkim { # BinSkim checks the exact mitigations the native project enables in # CMakeLists.txt (CFG/XFG, CET, ASLR/HighEntropyVA, DEP, /GS, stack cookies, @@ -288,6 +308,7 @@ if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]:: $steps = [ordered]@{ WinMerge = { Add-WinMergeToUserPath } + VsWhere = { Add-VsWhereToUserPath } BinSkim = { Install-BinSkim } GitConfig = { Set-GlobalGitConfig } }