When deploying Windows 10 one of the most common things you want to do is to modify the default wallpaper. Windows 10 uses different backgrounds depending on the resolution you use. If you use any of the following resolutions, 768 x 1024, 768 x 1366, 1024 x 768, 1200 x 1920, 1366 x 768, 1600 x 2560, 2160 x 3840, 2560 x 1600, 3840 x 2160 the file matching the resolution in the following folder %Windir%\Web\4K\Wallpaper\Windows will be used.
If the resolution used doesn’t match any of the above resolutions the default background %Windir%\Web\Wallpaper\Windows\img0.jpg will be used instead.
So a script that replaces these files will do the trick, the files however are owned by TrustedInstaller and TrustedInstaller is the only user that has permissions to change it as well.
To be able to replace them using a script either in MDT or SCCM we need to take ownership of the files and then change the permissions on them so we can replace them with our own custom background images.
I have created to script that can be used, on old school .cmd file and a Powershell script both works, so you can choose which one you want to use. Place your own custom backgrounds in the 4K folder and the img0.jpg file in the same folder as the script like this.
Important to note as well, if you use SCCM to deploy the script the System account will be used, you use MDT you need to change this to Administrators instead for the script to work as the Task Sequence isn’t executed in System context.
Download the script and create a package that can be used by either a “Run Command Line” step or “Run Powershell Script” step in the task sequence.
The .CMD file content:
takeown /f %WinDir%\WEB\wallpaper\Windows\img0.jpg
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
And the Powershell Script:
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)'
Remove-Item c:\windows\WEB\wallpaper\Windows\img0.jpg
Remove-Item C:\Windows\Web\4K\Wallpaper\Windows\*.*
Copy-Item $PSScriptRoot\img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
Copy-Item $PSScriptRoot\4k\*.* C:\Windows\Web\4K\Wallpaper\Windows
Both scripts can be downloaded here as well in this .zip file.
So why not just change the default background using a GPO for instance? One reason would be that you miss out on the dynamic selection of background that matches your resolution.
If you do this at the WinPE phase of a deployment, you don’t need to change any permissions as you are working with the offline OS. I wrote a blog about that: https://smsagent.wordpress.com/2015/06/16/setting-the-default-windows-wallpaper-during-os-deployment/ 🙂
I wonder if just doing a straight robocopy of a folder which already contains your custom resized images over the top of the current 4k\wallpaper folder would work or be easier?
Hi,
If you copy them i WinPE before the Windows 10 Operating System starts up then the file permissions are not enforced so then it would work.
/Jörgen
Have you found it ever using the wrong res? Which may not be noticeable as it stretches the image. I think it might be using 1024 768 during OSD on my test machine atleast.
To check just go to the properties of c:\windows\web\wallpaper\Windows\img0.jpg
Disregard prev post.
This isn’t working with my build it seems, just defaults to img0.jpg
Sorry for all the comments, just trying to get how Microsoft is working I think. It seems to be working, just the registry doesn’t match up. It’s stored in C:\Users\%Username%\AppData\Roaming\Microsoft\Windows\Themes\CachedFiles
I attempted to use your option to install at winpe and as such inject powershell capability into the boot image but each time it kept failing when i had to distribute the boot image. I have no idea why. Send me an email if you have any idea but its most frustrating. I’m attemping to use the legacy .cmd method as documented in this blog
Would this by chance work in Windows 8.1?
@Trevor – it doesn’t appear $OSDTargetSystemRoot is a valid variable in MDT per http://www.hayesjupe.com/sccm-and-mdt-list-of-variables/
your hijacking of this article and suggesting others use your solution rather than a solution offered here that works caused a derailment in at least one person.
thank you for your help, but please verify your solution meets the needs of the original topic of the article which is “Replacing default wallpaper in Windows 10 using Script/MDT/SCCM”
Snyggt Jörgen! 😀
Jag hade hittat att man skulle byta ut img0.jpg, men inte förstått att man var tvungen att ta över äganderätten utav filerna!
Jag skall testa! 🙂
Nice script. I would suggest adding quotes around “%~dp0img0.jpg” and “%~dp04k\*.*” so that if they resolve to a path with spaces, they will work.
What do you do for a Surface Pro 3 looking for a resolution of 2160×1440? During WinPE, I have a script that copies my custom background which I named img0_2160x1440.jpeg to %Windir%\Web\4K\Wallpaper\Windows but it does not automatically set my custom image as the default background?
Has anyone got a custom background image to work on a Surface Pro 3? We’ve tried replacing the default img0 and also created one in the 4k folder with the correct resolution but none of these are working for us. Any ideas?
This works great. Thanks
When i run the Powershell script as custom task in MDT i get permission denied to the folder on C:\Windows\Web
Hi,
For MDT you need to change the permissions to grant to Adminstrators instead of System as the MDT Task Sequence is executed as local Administrator and not system.
/Jörgen
Hi Jorgen, could you please provide more details about how exactly to grant “Administrators” permission on MDT ?
Thanks
Hi Jörgen,
I have tried this script into powershell but it did not work.
I get an ” Access to the path is denied” error when it tries to remove-item and copy-item.
Can you please advice?
Hi,
How did you test it? you must run it under System context like using Psexec because it adds permissions to the files for System.
/Jörgen
I can’t get this to work. I set it up exactly as you say (I think) but I just get a black background in the local administrator profile when the task sequence is finished. I see the wallpaper jpegs in the c:\windows\web\wallpaper\windows and c:\windows\web\4k\wallpaper\windows directories but it’s not applying them. The task sequence is a UDI task sequence in SCCM 1606. I’m running it on a blank VM. Any ideas?
So it works for me, but when my users upgrade from one Windows 10 build to another, my images are replaced.
Any workarounds?
Hi,
I wrote a post on how to upgrade using a Task Sequence which makes it possible to do this kind of modifications. https://4sysops.com/archives/upgrading-windows-10-sccm-servicing-or-task-sequence/
/Jörgen
So you have to have SCCM to do this?
What if use a scheduled task that runs this script every time the computer starts up? Is that a potential workaround?
this works great with a VM but fails on tablets with UEFI? no cdrive. any ideas how to make it work for both bios and UEFI?
Hi,
No Cdrive? which drive do you deploly the OS to?
/jörgen
On Windows 10 v1607 default Media VL using MDT 8443.
It appears that the following commands work correctly in the batch file:
takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\Web\4K\Wallpaper\Windows\*.*
The next commands work correctly in the batch file:
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
The last commands both are failing with “Access is denied”.
As stated in this article when using MDT it installs using the local administrator account. So change
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
to
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /Grant Administrators:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant Administrators:(F)
thank you so much, 21h2 this stopped working for us. Your fix to our script was flawless.
I’m having trouble getting this to work exactly. I have tried both the Powershell script and the command line script but I just get a black background in the local administrator profile when the task sequence completes. I don’t see any wallpaper jpegs in the c:\windows\web\wallpaper\windows but all of the images did get copied to c:\windows\web\4k\wallpaper\windows but it’s not applying them. I’m not sure why the 4K folder copies over without issue but img0.jpg does not, seeing as how they are using the same commands in the script. Any thoughts?
@Colton
Did you ever figure this out? I want to set a custom 1920 x 1080 default wallpaper and I’ve tried adding it to both folders but I end up with a black screen for all new users.
So i had the same issues as a few others. I noticed when I RDPed the other day the wallpaper worked but not on the console. HAS to be the resolution. I created a file and named it img0_1920x1080.jpg and it works! So for all of you going through hell to resolve this i hope i made your day easier. I wasted multiple days on it 🙁
You can also configure a startup script that will apply a specific wallpaper using the function that I wrote recently.
http://joseespitia.com/2017/09/15/set-wallpaper-powershell-function/
So when I try to run these scripts from MDT in WinPE, it fails to find the C:\Windows\Web\ or C:\Window\Web\4k folders. It’s like the paths don’t exist yet. When I try the task after install, say after state restore but before windows updates, it still fails. Any suggestions?
Version without deleting existing images
TESTED OS Windows 10 version 1709 Build 1629.64
Use> MDT 8443, and ADK 1709
Deployment Share F:\W10_1709_Creation
Images location F:\W10_1709_Creation\Scripts\Wallpaper
Create new cmd in MDT Custom Group, add a new command, choose your preferred name
Command line point to our Wallpaper folder inside of scripts folder
%SCRIPTROOT%\Wallpaper\setwallpaper.cmd
setwallpaper.cmd contain
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 Administrator:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant Administrator:(F)
rename C:\Windows\Web\Wallpaper\Windows\img0.jpg img1.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_1024x768.jpg img1_1024x768.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_1200x1920.jpg img1_1200x1920.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_1366x768.jpg img1_1366x768.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_1600x2560.jpg img1_1600x2560.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_2160x3840.jpg img1_2160x3840.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_2560x1600.jpg img1_2560x1600.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_3840x2160.jpg img1_3840x2160.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_768x1024.jpg img1_768x1024.jpg
rename C:\Windows\Web\4K\Wallpaper\Windows\img0_768x1366.jpg img1_768x1366.jpg
xcopy /Q /R /Y img0.jpg C:\windows\WEB\wallpaper\Windows\
xcopy /Q /R /Y img0_1024x768.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_1200x1920.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_1366x768.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_1600x2560.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_2160x3840.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_2560x1600.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_3840x2160.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_768x1024.jpg C:\Windows\Web\4K\Wallpaper\Windows\
xcopy /Q /R /Y img0_768x1366.jpg C:\Windows\Web\4K\Wallpaper\Windows\
v-juanm
where are you running the CMD from in your SCCM or MDT task? or anyone else that has had success with this script?
v-juanm
where are you running the script in your SCCM or MDT task sequence? or anyone else that has had success in deploying the wallpapers with this script? what about the lockscreen?
Thanks,
Josh
Shouldn’t ownership and permissions be returned to normal on those files when done? Or, since they are just wallpaper files, are you not concerning yourself with that?
Hi,
As it is only background pictures and still restricted to System, I thought it was ok.
regards,
Jörgen
Hi,
This works to a certain extent for us. Both 4k images and C:\Windows\Web\Wallpaper\Windows image get copied correctly; however, the only images that gets applied is img0, the ones in the 4k folder are being ignored. Do you have any thoughts of why that is? Thank you for posting this!
Best,
Lucian
We use this method, but now finding out when we install a feature update (1709 in our case) the wallpaper is replaced with the default Windows wallpaper again. Anyone else experienced this issue?
yes, you have to re-run the replacement
looks like as Windows doesn’t like that approach.
When you run a sfc /scannow, it will restore the original files:
00004d2c [SR] Repairing corrupted file \??\C:\WINDOWS\Web\4K\Wallpaper\Windows\img0_1366x768.jpg from store
anyone has an idea how to fix that?
From where do the scripts run? On the GM to be captured?
Thanks
FYI, Just Delete the c:\windows\WEB\wallpaper\Windows\img0.jpg ,
Do not replace it. It will auto recreate itself from one of the default wallpapers in C:\Windows\Web\4K\Wallpaper\Windows that you replaced. To enforce the new wallpaper, point your policy to the c:\windows\WEB\wallpaper\Windows\img0.jpg
If doing this after the OSD,
Run As System (psexec -I -s cmd.exe)
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 %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows
The script used to change Wallpaper doesn’t work as wanted for me (W10 1709).
The default wallpapers are correctly removed and mine is copied. But on first boot, it’s still the default one which is displayed .. Even with another reboot.
Otherwise, in the personnalize menu, i only see my wallpaper, but it doesn’t apply automatically.
Have you already encountered this issue ? How can I resolve it ?
Thanks
I am having the exact same problem, with a new 1803 image. Img0 is replaced, and in Personalization, it says it is the selected image. But the actual wallpaper is the Windows 10 default. This was working well in 1703 for me.
same. This worked well in v1607, but I recently upgraded my image to 1709 and I’m seeing the same behavior
Is there a way to use this method to apply a TILED image regardless of resolution it picks?
if you use a new installation just add a folder named $OEM$ and place it in the Sources folder of Windows. Add another folder below that named $1, $1 means the Windows partition.
Finish the folder structure like this USB-Drive\Sources\$OEM$\$1\Windows\web\4K\Wallpaper\Windows and place your custom wallpapers there. Don’t forget the folder for the img0.jpg file.
During installation they will replace the default images without the need for scripting or file ownership or taking away user functions
Hi Jorgen,
I am little confused about the location of the script and img.0 and 4K folder on MDT. Where exactly to copied and TS location.
I am trying this script and the deployment finished with errors and no background changed on Win 1803.
Hi Jorgen,
I’ve been able to get your script working fine – if I run it from an elevated PowerShell prompt. However, during imaging (Placed in my SCCM TS as the very last step) the script fails. Any recommendations?
Hi,
It shouldn’t be working from an elevated command prompt as that will run it as local admin the script is made for running under System Context to be used in SCCM..
It works great for me.. but it must use SYSTEM in the script for it to work in SCCM.
Regards,
Jörgen
to run the script as the system account use
psexe.exe -s -i cmd.exe
or
psexec.exe -s -i powershell
you will get a cmd prompt or powershell windows that are running as system. execute the script and all is well.
Thanks Jörgen for this post