Category filter

Script to set lock screen background for Windows device

Organizations often need to standardize the appearance of their devices with their branding logo or to display important information. For a lock screen background, organizations can set an image with any information, for instance, any information that can be helpful if the device gets lost. This can be done by deploying a script, allowing administrators to choose an image to set lock screen background on Windows devices remotely. Using Hexnode’s Execute Custom Script action, IT admins can execute the script to set the lock screen background on Windows devices.


The script is supported on Windows 10 and 11 devices.


The sample script provided below are adapted from third-party open source sites.

PowerShell script to set lock screen background

This PowerShell script creates and modifies a registry key within ‘HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP’. The script defines the names of corresponding values for the registry key. The variable $keyName is set to ‘LockScreenImagePath’, which is the name of the key in the registry. Replace the actual path of the image file in the place of ‘C:\Path\to\the\file’.

The New-Item cmdlet is used to create a new registry key at the specified path, with -Force ensuring that any existing item with the same name is overwritten. Set-ItemProperty cmdlet sets the value of the newly created registry key to the specified image path.

Batch script to set lock screen background

The Batch script works much in a way similar to the PowerShell script.

After executing the script, restart the Windows device for the changes to occur. The scripts also restrict the user from changing the lock screen.

You can verify the output of the script by navigating to the Action History tab.

Verify the output of the script to set lock screen background from the Hexnode UEM console


  • The lock screen will have a dark background if the image file path doesn’t exist on the device.
  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.
  • Sample Script Repository