# Set-EventSaverDisable.ps1 # # Turn the EventSaver shopfloor screensaver OFF fleet-wide and undo its # side effects. Runs under GE-Enforce (SYSTEM) every cycle. Idempotent + # silent (SYSTEM context - no window). # # Self-excludes the canary test host: pass -ExceptHost and this script # does nothing on that PC, so the (canary-gated) enable entries keep it on # there while every other shopfloor PC is cleaned. # # Undoes: screensaver registry (per-user), the EventSaver-Enable fallback # task, the never-off power policy, and the staged .scr/.ini. [CmdletBinding()] param( [string]$ExceptHost = '', [string]$ScrPath = 'C:\Windows\System32\EventSaver.scr', [string]$TaskName = 'EventSaver-Enable', [int] $MonitorMinutes = 15, # restore a sane monitor-off (was Never) [int] $StandbyMinutes = 20 # restore a sane sleep (was Never) ) $ErrorActionPreference = 'Continue' # leave the canary host alone - the enable entries own it there if ($ExceptHost -and ($env:COMPUTERNAME -ieq $ExceptHost)) { exit 0 } function Disable-Saver($deskKey) { if (Test-Path $deskKey) { Set-ItemProperty -Path $deskKey -Name 'ScreenSaveActive' -Value '0' -Type String -Force -ErrorAction SilentlyContinue Remove-ItemProperty -Path $deskKey -Name 'SCRNSAVE.EXE' -ErrorAction SilentlyContinue } } # 1. screensaver off in the default profile + every loaded user hive Disable-Saver 'Registry::HKEY_USERS\.DEFAULT\Control Panel\Desktop' Get-ChildItem 'Registry::HKEY_USERS' -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -match '^S-1-5-21' -and $_.PSChildName -notmatch '_Classes$' } | ForEach-Object { Disable-Saver "Registry::HKEY_USERS\$($_.PSChildName)\Control Panel\Desktop" } # 2. remove the self-clearing fallback task if present if (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) { Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false -ErrorAction SilentlyContinue } # 3. restore power (undo the EventSaver never-off) & powercfg /change monitor-timeout-ac $MonitorMinutes 2>&1 | Out-Null & powercfg /change standby-timeout-ac $StandbyMinutes 2>&1 | Out-Null # 4. remove staged binary + config (harmless if already gone) Remove-Item -LiteralPath $ScrPath -Force -ErrorAction SilentlyContinue Remove-Item -LiteralPath ($ScrPath -replace '\.scr$', '.ini') -Force -ErrorAction SilentlyContinue exit 0