fix(branding): guard reg unload, set ErrorAction in libs, accent field rename, test hive unload + assertions
This commit is contained in:
@@ -47,7 +47,11 @@ function Invoke-WithHive {
|
||||
& reg load "HKLM\$Name" $HivePath | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) { throw "reg load $Name ($HivePath) failed" }
|
||||
try { & $Body "Registry::HKEY_LOCAL_MACHINE\$Name" }
|
||||
finally { [gc]::Collect(); Start-Sleep -Milliseconds 500; & reg unload "HKLM\$Name" | Out-Null }
|
||||
finally {
|
||||
[gc]::Collect(); Start-Sleep -Milliseconds 500
|
||||
& reg unload "HKLM\$Name" | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) { Write-Warning "reg unload $Name failed ($LASTEXITCODE) — hive may be leaked" }
|
||||
}
|
||||
}
|
||||
|
||||
if ($Mode -eq 'Offline') {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"desktop": {
|
||||
"wallpaper": "wallpaper.jpg",
|
||||
"theme": "SilverMetal.theme",
|
||||
"accentBgr": "00d4ff",
|
||||
"accentColor": "00d4ff",
|
||||
"darkMode": true,
|
||||
"lockWallpaper": false
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. "$PSScriptRoot\RegistryHelpers.ps1"
|
||||
|
||||
function Set-OemInformation {
|
||||
@@ -34,8 +35,8 @@ function Set-DesktopBranding {
|
||||
Set-SmRegValue -Root $DefaultUserRoot -SubKey $p -Name 'AppsUseLightTheme' -Type DWord -Value 0
|
||||
Set-SmRegValue -Root $DefaultUserRoot -SubKey $p -Name 'SystemUsesLightTheme' -Type DWord -Value 0
|
||||
}
|
||||
# Accent (cyan). BGR DWORD from manifest hex (stored little-endian as 0x00BBGGRR).
|
||||
$bgr = [Convert]::ToInt32($Manifest.desktop.accentBgr,16)
|
||||
# Accent color as COLORREF (0x00RRGGBB). #00d4ff = cyan.
|
||||
$bgr = [Convert]::ToInt32($Manifest.desktop.accentColor,16)
|
||||
Set-SmRegValue -Root $DefaultUserRoot -SubKey 'Software\Microsoft\Windows\DWM' -Name 'AccentColor' -Type DWord -Value $bgr
|
||||
Set-SmRegValue -Root $DefaultUserRoot -SubKey 'Software\Microsoft\Windows\DWM' -Name 'ColorizationColor' -Type DWord -Value $bgr
|
||||
if (-not $Manifest.desktop.lockWallpaper) { return }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Write a registry value under an arbitrary hive root (a live HKLM:/HKCU: path
|
||||
# OR a loaded offline hive exposed as a PSDrive). Creates intermediate keys.
|
||||
|
||||
@@ -38,6 +38,7 @@ Describe 'Branding layer writers' {
|
||||
$k.Manufacturer | Should -Be 'SilverLABS'
|
||||
$k.Model | Should -Be 'SilverMetal Windows'
|
||||
$k.SupportURL | Should -Be 'https://silverlabs.uk'
|
||||
$k.SupportHours | Should -Be '24/7 community + paid SLA'
|
||||
$k.Logo | Should -Be 'C:\Windows\System32\oemlogo.bmp'
|
||||
}
|
||||
|
||||
@@ -58,6 +59,7 @@ Describe 'Branding layer writers' {
|
||||
$k = Get-ItemProperty "$script:sw\Policies\Microsoft\FVE"
|
||||
$k.UseCustomRecoveryMessage | Should -Be 1
|
||||
$k.RecoveryMessage | Should -Be 'SilverMetal Windows. Locked out? silverlabs.uk'
|
||||
$k.RecoveryUrl | Should -Be 'https://silverlabs.uk'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +72,7 @@ Describe 'Apply-Branding -Mode Offline' {
|
||||
foreach ($h in @("$script:mount\Windows\System32\config\SOFTWARE","$script:mount\Users\Default\NTUSER.DAT")) {
|
||||
reg load 'HKLM\SM_SEED' (New-Item -ItemType File -Force $h | Select-Object -Expand FullName) 2>$null | Out-Null
|
||||
}
|
||||
& reg unload 'HKLM\SM_SEED' 2>$null | Out-Null
|
||||
# The above seed is best-effort; if reg can't init an empty file, the apply
|
||||
# script creates the hives via reg load of the path it expects.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user