Script to change wallpaper in windows 10?
Asked Answered
D

3

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

Denouement answered 5/11, 2015 at 18:17 Comment(4)
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.Fledgling
We have tried with xml as well still no luck. So I just want to run a batch file in the task sequence if possibleDenouement
is powershell an option? If so, there is a script for thisManlike
Yes of course that might be betterDenouement
M
17

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"
Manlike answered 5/11, 2015 at 21:33 Comment(4)
@Denouement like I said in my first comment. You could have done the same registry tweak with a batch file.Fledgling
Is there a way to make this change for any user that logs into the computer for the first time?Denouement
Does not update on my Windows 10 (10.0.17134.0 - 1803 (Redstone 4) "April 2018 Update").Mesquite
@TNT, my wallpaper did not change until I logged out and back in.Phonemics
M
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).

Maynardmayne answered 16/9, 2016 at 13:18 Comment(1)
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!Colan
C
-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}")
Coomb answered 20/1, 2019 at 5:22 Comment(1)
Well, it's just an automation, could be faulty or sometimes dangerous.Vegetate

© 2022 - 2024 — McMap. All rights reserved.