Skip to content

Latest commit

 

History

History
104 lines (67 loc) · 4.38 KB

File metadata and controls

104 lines (67 loc) · 4.38 KB

LockScreen API

This documentation list methods of changing the Windows lock screen.

Windows 7

SpotlightDL v1.x only

Windows 7 has an OEMBackground feature in registry allowing custom Logon Screen background:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background]
"OEMBackground"=dword:00000001

Then the image has to be placed in C:\Windows\System32\oobe\info\backgrounds\backgroundDefault.jpg.

Windows 7 enforces a limit of 250 KiB, so SpotlightDL will recompress the image to the highest quality fitting in that limit. This results in lower quality lock screen images than Windows 8 and greater, but works without patching anything on the system so the feature is safe to use.

Windows 8 and greater

User LockScreen API

SpotlightDL v2.x only

Setting a lockscreen image for the current user account is straightforward using the .NET API:

var file = await StorageFile.GetFileFromPathAsync(lockScreenImageFilePath);
await LockScreen.SetImageFileAsync(file);

Reference: LockScreen.SetImageFileAsync

System LockScreen Policy (GPO)

SpotlightDL v2.x only

Require administrator privileges. Works will all editions except Home and Pro.

gpedit.msc

Computer Configuration
 +- Policies
     +- Administrative Templates
         +- Control Panel
             +- Personalization

Set Force a specific default lock screen image to the desired image path.

Registry

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Personalization]
"LockscreenImage"="C:\\Path\\To\\lockscreen.png"

References:

System LockScreen Policy (CSP)

SpotlightDL v2.x only

Require administrator privileges. Works will all editions except Home. Windows 10 1709 or greater.

Note

This policy will lock down the lockscreen settings in personalization panel. Remove the "PersonalizationCSP" registry key to unlock.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP]
"LockScreenImagePath"="C:\\Path\\To\\lockscreen.png"

References:

By manipulating system files

SpotlightDL v1.x only

Require administrator privileges. Works with any Windows edition including Home, but might break things.

The global lock screen images for Windows 8+ are stored as C:\Windows\Web\Screen\imgXXX.jpg. SpotlightDL v1.x backups each image as imgXXX.jpg.bak if it does not already exists, then overwrite this file.

The lock screen image cache, located at C:\ProgramData\Microsoft\Windows\SystemData\S-1-5-18\ReadOnly\LockScreen_*, must be cleared for the change to take effect.

SpotlightDL gets around NTFS permissions on these folders being locked down to TrustedInstaller by setting the local Administrators group as new owner of the relevant files and folders, and granting full control to this group. Then, programs running as administrator can overwrite the lockscreen image and clear the cache.

This way of replacing the lockscreen is basically a C# implementation of this script, avoiding the use of the takeown and iacls commands which are not reliable due to command-line switches changing depending on system locale.