Hi,
I have created a powershell script to activate a specific screensaver, password enable it and set the idle timeout value, but it does not work when I try to run it from the PulseWay Web interface.
I have also tried it from a batch script, but it does not work either.
Both scripts work fine when running them directly from the local computer.
The Powershell script it as follows:
#Values to customize
$ScreenSaveActive = 1 #set to 1 if you want the screensaver enabled, 0 to disable
$TimeOutValue = 60 # number of idle seconds before screensaver gets active
$ScreenSaverFile = "C:\Windows\system32\mystify.scr" # full path to screensaver file
$ScreenSaverIsSecure = 1 # set to 1 if you need a password to get out of screensaver, a.k.a. unlocking the pc
#If the screensaver is not compliant with $ScreenSaveActive, we reset it to the preferred value
if((Get-ItemProperty -Path "hkcu:control panel\desktop" -Name "ScreenSaveActive").ScreenSaveActive -ne $ScreenSaveActive)
{ Set-ItemProperty -Path "hkcu:control panel\desktop" -Name "ScreenSaveActive" -Value $ScreenSaveActive }
#If user set screensaver timeout to a value larger than 1200 seconds (20 minutes), we set the value back to 1200 seconds
[int]$Current_TimeOutValue = (Get-ItemProperty -Path "hkcu:control panel\desktop" -Name "ScreenSaveTimeOut").ScreenSaveTimeOut
if($Current_TimeOutValue -eq 0 -OR $Current_TimeOutValue -gt 1200)
{ Set-ItemProperty -Path "hkcu:control panel\desktop" -Name "ScreenSaveTimeOut" -value 1200 }
#If no screensaver file is set or if the path doesn't exist anymore, we set it to the blank screensaver
$Current_ScreenSaverFile = (Get-ItemProperty -Path "hkcu:control panel\desktop" -Name "SCRNSAVE.EXE")."SCRNSAVE.EXE"
if($Current_ScreenSaverFile -eq "" -OR (Test-Path $Current_ScreenSaverFile) -eq $false)
{ Set-ItemProperty -Path "hkcu:control panel\desktop" -Name "SCRNSAVE.EXE" -Value $ScreenSaverFile }
#If the screensaver "lock" is not compliant with $ScreenSaverIsSecure, we reset it to the preferred value
if((Get-ItemProperty -Path "hkcu:control panel\desktop" -Name "ScreenSaverIsSecure").ScreenSaverIsSecure -ne $ScreenSaverIsSecure)
{ Set-ItemProperty -Path "hkcu:control panel\desktop" -Name "ScreenSaverIsSecure" -Value $ScreenSaverIsSecure }
#Before our changes become active in the current Windows session, we need to run the following command more than 3 times
for ($i=1; $i -le 4; $i++)
{ rundll32.exe user32.dll, UpdatePerUserSystemParameters }
I have also tried this from batch script, but it does not work either.
@echo off
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v SCRNSAVE.EXE /t REG_SZ /d C:\Windows\System32\Mystify.scr /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 1 /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 60 /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaverIsSecure /t REG_SZ /d 1 /f