X-Git-Url: https://vilimpoc.org/repos/dotfiles/blobdiff_plain/2bbc9b414ffb45df936ca1169795cb8e07bb1863..refs/heads/master:/setup-windows-no-uac.ps1?ds=sidebyside 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 } }