5

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

user1342164
  • 1,434
  • 13
  • 44
  • 83
  • How are you deploying Windows 10? If you are doing this with an unattended answer file wouldn't it be easier to change that way? If you are on a domain, just push down a group policy. Last option would be to change the registry settings with a batch file. That would be a lot easier then running on the commands you are using. – Squashman Nov 05 '15 at 18:32
  • We have tried with xml as well still no luck. So I just want to run a batch file in the task sequence if possible – user1342164 Nov 05 '15 at 18:53
  • is powershell an option? If so, there is a script for this – Michael Palermo Nov 05 '15 at 20:06
  • Yes of course that might be better – user1342164 Nov 05 '15 at 20:06

3 Answers3

16

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"
TeWu
  • 5,928
  • 2
  • 22
  • 36
Michael Palermo
  • 296
  • 2
  • 9
4

I know this has already been answered, but if someone wants to do this in a batch file the icacls lines need to use /reset instead of the /grant... something like:

takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /reset
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

should work (as long as it is being run by an Administrative account).

Stephen Lee Parker
  • 1,215
  • 9
  • 19
  • I have seen the takeown command on other websites as a solution, but that icacls is critical and this is the only answer which worked for me! – shelbypereira Dec 13 '22 at 09:37
-1
set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.SendKeys("^ ")
    WshShell.SendKeys("+{F10}")
    WshShell.SendKeys("N")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{DOWN}")
    WshShell.SendKeys("{ENTER}")