Windows – Set Screensaver Policy

email me

If creating a policy package for SCCM: Compile to EXE, add the EXE you just created to SCCM as a package: Create Package > Environment > Program can run: Only when user is logged on > Run with user rights.


Registry

REG ADD “HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop” /v ScreenSaveActive /d 1 /f

REG ADD “HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop” /v ScreenSaveTimeOut /d 60 /f

REG ADD “HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop” /v SCRNSAVE.EXE /d “C:\Windows\System32\Mystify.scr” /f

 

Notes

If creating a policy package for SCCM: Compile to EXE, add the EXE you just created to SCCM as a package: Create Package > Environment > Program can run: Only when user is logged on > Run with administrator rights.

on error resume next

Set objShell = CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject")

Const HKEY_LOCAL_MACHINE = &H80000002
Const OverwriteExisting = TRUE
Const POPUP_TITLE = "User To SID Conversion"

strComputer = "."

objShell.Run "cmd /c copy /y TheScreensaver.scr \\%computername%\c$\Windows\system32\TheScreensaver.scr",0,true

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

For Each objSubkey In arrSubkeys
on error resume next
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get("Win32_SID.SID='" & objSubkey & "'")
strUser = objAccount.AccountName

objSubkey = trim(objSubkey)'trims whitespace
strUser = trim(strUser)'trims whitespace

if strUser = "Administrator" then strUser=""
if strUser = "Media" then strUser=""
if strUser = "Default" then strUser=""

if strUser <> "" then

on error resume next

objShell.Run "REG ADD " & chr(34) & "HKEY_Users\" & objSubkey & "\Software\Policies\Microsoft\Windows\Control Panel\Desktop" & chr(34) & " /v ScreenSaveActive /d 1 /f",0,false

objShell.Run "REG ADD " & chr(34) & "HKEY_Users\" & objSubkey & "\Software\Policies\Microsoft\Windows\Control Panel\Desktop"" /v ScreenSaveTimeOut /d 120 /f",0,false

objShell.Run "REG ADD " & chr(34) & "HKEY_Users\" & objSubkey & "\Software\Policies\Microsoft\Windows\Control Panel\Desktop"" /v SCRNSAVE.EXE /d ""C:\Windows\System32\TheScreensaver.scr"" /f ",0,false

end if

Next