diff --git a/plugins/geenforce/seed_display_scope.py b/plugins/geenforce/seed_display_scope.py index fe05f94..1a1495d 100644 --- a/plugins/geenforce/seed_display_scope.py +++ b/plugins/geenforce/seed_display_scope.py @@ -198,19 +198,70 @@ Get-ChildItem -LiteralPath $startup -Filter '*.url' -ErrorAction SilentlyContinu }} catch {{}} }} -# Legacy HKLM Run autostarts the OLD Dashboard/Lobby Inno installers planted. -# The .lnk/.url sweep above misses these -- a Run value relaunches the old kiosk -# URL at every logon and BEATS our Startup shortcut (this is why a display with -# our new .lnk still opened the old page). Purge them, then kill any running -# old-URL Edge so the display self-heals to the resolved target this cycle. -$legacyRun = 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run' -foreach ($legacyName in @('GE Aerospace Dashboard','GE Aerospace Lobby Display')) {{ - try {{ - if ($null -ne (Get-ItemProperty -LiteralPath $legacyRun -Name $legacyName -ErrorAction SilentlyContinue)) {{ - Remove-ItemProperty -LiteralPath $legacyRun -Name $legacyName -Force -ErrorAction SilentlyContinue - Write-Host "removed legacy Run value $legacyName" +# Legacy autostarts the OLD Dashboard/Lobby Inno installers planted keep +# relaunching the dead old URL (-> 404 white screen) and BEAT our shortcut. They +# hide in several places: the 32-bit Inno installer's HKLM Run write is +# WOW64-redirected into Wow6432Node (invisible to 64-bit tooling), and copies +# can sit in per-user hives, RunOnce, or the policy Run key. Sweep ALL of them +# by legacy NAME and by VALUE (any Run entry whose data points at the old URLs), +# across the native + Wow6432Node views and every loaded user hive, plus every +# per-user + common Startup folder. +$legacyNames = @('GE Aerospace Dashboard','GE Aerospace Lobby Display') +$oldUrlPattern = 'tv-dashboard|shopfloor-dashboard' + +$regRoots = @('HKLM:\\SOFTWARE', 'HKLM:\\SOFTWARE\\Wow6432Node') +if (-not (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {{ + New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS -ErrorAction SilentlyContinue | Out-Null +}} +try {{ + Get-ChildItem 'Registry::HKEY_USERS' -ErrorAction Stop | + Where-Object {{ $_.PSChildName -notmatch '_Classes$' }} | + ForEach-Object {{ + $regRoots += "HKU:\\$($_.PSChildName)\\SOFTWARE" + $regRoots += "HKU:\\$($_.PSChildName)\\SOFTWARE\\Wow6432Node" }} - }} catch {{}} +}} catch {{}} + +$runSubkeys = @( + 'Microsoft\\Windows\\CurrentVersion\\Run', + 'Microsoft\\Windows\\CurrentVersion\\RunOnce', + 'Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run' +) +foreach ($root in $regRoots) {{ + foreach ($sub in $runSubkeys) {{ + $key = Join-Path $root $sub + if (-not (Test-Path -LiteralPath $key)) {{ continue }} + $props = Get-ItemProperty -LiteralPath $key -ErrorAction SilentlyContinue + if (-not $props) {{ continue }} + foreach ($prop in $props.PSObject.Properties) {{ + if ($prop.Name -like 'PS*') {{ continue }} + if (($legacyNames -contains $prop.Name) -or ("$($prop.Value)" -match $oldUrlPattern)) {{ + Remove-ItemProperty -LiteralPath $key -Name $prop.Name -Force -ErrorAction SilentlyContinue + Write-Host "removed legacy autostart $key -> $($prop.Name)" + }} + }} + }} +}} + +$startupDirs = @($startup, (Join-Path $env:Public 'Desktop')) +Get-ChildItem 'C:\\Users' -Directory -ErrorAction SilentlyContinue | ForEach-Object {{ + $startupDirs += (Join-Path $_.FullName 'AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup') +}} +foreach ($dir in ($startupDirs | Select-Object -Unique)) {{ + if (-not (Test-Path -LiteralPath $dir)) {{ continue }} + Get-ChildItem -LiteralPath $dir -Filter '*.lnk' -ErrorAction SilentlyContinue | ForEach-Object {{ + $drop = ($_.Name -like 'GE Aerospace *') + if (-not $drop) {{ + try {{ + $existing = $shell.CreateShortcut($_.FullName) + if ("$($existing.Arguments)" -match $oldUrlPattern) {{ $drop = $true }} + }} catch {{}} + }} + if ($drop) {{ + Remove-Item -LiteralPath $_.FullName -Force -ErrorAction SilentlyContinue + Write-Host "removed legacy startup shortcut $($_.FullName)" + }} + }} }} try {{ Get-CimInstance Win32_Process -Filter "Name = 'msedge.exe'" -ErrorAction SilentlyContinue |