Category filter
Script to set Wallpaper on Windows 10
Hexnode UEM automates the execution of proactive IT tasks on Windows 10 with the help of
custom scripts. For example, you can create Batch file scripts or PowerShell scripts to perform necessary operations, which can be executed on the devices remotely from the Hexnode console.
This doc helps you create custom scripts to change the desktop wallpaper on Windows devices.
PowerShell script to set the wallpaper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$filePath = "C:\users\qa\Documents\hexnode.jpg" Write-Host "-----starting script execution-----" try{ $status = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS Function Set-WallPaper($sid) { if(Test-Path "HKU:\${sid}") { Write-Host "Changing wallpaper for user with sid:",$sid Set-ItemProperty -path "HKU:\${sid}\Control Panel\Desktop\" -name wallpaper -value $filePath } #rundll32.exe user32.dll, UpdatePerUserSystemParameters --force } $userDetails=Get-wmiobject win32_useraccount | where-object{$_.status -eq 'ok'} foreach($user in $userDetails){ $sid=$user.SID Set-WallPaper($sid) } } catch { Write-Host "Error occured while running script -> ",$_.Exception.Message } Write-Host "-----script execution completed successfully-----" Write-Host "Apply Restart device action to reflect the changes" |
Ensure the wallpaper image exists on the device by the specified name at the designated path. Since the script works on this image, its unavailability can cause the action to fail. Also, it requires a restart action for the changes to be reflected on the device.