Script to change wallpaper in windows 10?

user1342164 picture user1342164 · Nov 5, 2015 · Viewed 45.5k times · Source

I am trying to get a script to work that will change the default wallpaper for windows 10 because I will be deploying Win10 to all clients. When I run the batch code below, it is not changing the default wall paper. I see that the img0 file is in the correct directory C:\Windows\Web\Wallpaper\Windows but it is not changing the background. The code below is what I am using. I do get some access denied errors when trying to del C:\Windows\Web\4K\Wallpaper\Windows\img0_1366x768.jpg Access is denied.

takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\Web\4K\Wallpaper\Windows\*.*
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
del c:\windows\WEB\wallpaper\Windows\img0.jpg
del /q C:\Windows\Web\4K\Wallpaper\Windows\*.*
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

Any ideas what I am doing wrong? TIA

Answer

Michael Palermo picture Michael Palermo · Nov 5, 2015

Use Powershell to change the wallpaper. First, create a function like this:

Function Set-WallPaper($Value)
 {
    Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $value
    rundll32.exe user32.dll, UpdatePerUserSystemParameters
 }

Now call the function:

Set-WallPaper -value "path to wallpaper"