Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Windows 11
  • Intune
  • GitHub
  • About
CCMEXEC.COM – Enterprise Mobility

Replacing default wallpaper in Windows 10 using Script/MDT/SCCM

Posted on August 11, 2015 by Jörgen Nilsson

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.
Win10Backgrounds

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.
Win10Backgrounds1

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.

Win10Backgrounds2

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 %WinDir%\Web\4K\Wallpaper\Windows\*.*
icacls %WinDir%\WEB\wallpaper\Windows\img0.jpg /Grant System:(F)
icacls %WinDir%\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
del %WinDir%\WEB\wallpaper\Windows\img0.jpg
del /q %WinDir%\Web\4K\Wallpaper\Windows\*.*
copy %~dp0img0.jpg %WinDir%\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* %WinDir%\Web\4K\Wallpaper\Windows

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.

55 thoughts on “Replacing default wallpaper in Windows 10 using Script/MDT/SCCM”

  1. Trevor says:
    August 17, 2015 at 10:48 am

    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/ 🙂

    Reply
  2. Al says:
    September 18, 2015 at 3:09 am

    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?

    Reply
    1. Jörgen Nilsson says:
      September 20, 2015 at 9:23 pm

      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

      Reply
  3. Jay Connor says:
    September 21, 2015 at 1:12 am

    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

    Reply
  4. Jay Connor says:
    September 21, 2015 at 6:21 am

    Disregard prev post.
    This isn’t working with my build it seems, just defaults to img0.jpg

    Reply
  5. Jay Connor says:
    September 21, 2015 at 6:51 am

    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

    Reply
  6. Pingback: Windows 10 Customizations during OSD | GARYTOWN TECH BLOG
  7. sharpy says:
    December 2, 2015 at 1:09 am

    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

    Reply
  8. Isaac says:
    December 9, 2015 at 5:59 am

    Would this by chance work in Windows 8.1?

    Reply
  9. Matt says:
    January 25, 2016 at 10:21 pm

    @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”

    Reply
  10. Johan Claesson says:
    February 2, 2016 at 3:03 pm

    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! 🙂

    Reply
  11. Jason says:
    February 18, 2016 at 3:06 am

    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.

    Reply
  12. Ethan says:
    April 26, 2016 at 8:00 pm

    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?

    Reply
  13. Gerard says:
    April 26, 2016 at 8:32 pm

    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?

    Reply
  14. Joe says:
    June 17, 2016 at 11:01 pm

    This works great. Thanks

    Reply
  15. Garvin says:
    July 15, 2016 at 6:43 pm

    When i run the Powershell script as custom task in MDT i get permission denied to the folder on C:\Windows\Web

    Reply
    1. Jörgen Nilsson says:
      July 17, 2016 at 1:07 pm

      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

      Reply
      1. Nick says:
        August 7, 2018 at 12:16 am

        Hi Jorgen, could you please provide more details about how exactly to grant “Administrators” permission on MDT ?
        Thanks

        Reply
  16. Sachin says:
    August 16, 2016 at 5:05 pm

    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?

    Reply
    1. Jörgen Nilsson says:
      August 19, 2016 at 7:51 am

      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

      Reply
  17. Shane says:
    September 8, 2016 at 4:50 am

    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?

    Reply
  18. Jason says:
    September 23, 2016 at 3:55 am

    So it works for me, but when my users upgrade from one Windows 10 build to another, my images are replaced.

    Any workarounds?

    Reply
    1. Jörgen Nilsson says:
      September 23, 2016 at 11:06 am

      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

      Reply
  19. Jason says:
    September 25, 2016 at 8:14 pm

    So you have to have SCCM to do this?

    Reply
  20. Jason says:
    October 21, 2016 at 8:59 pm

    What if use a scheduled task that runs this script every time the computer starts up? Is that a potential workaround?

    Reply
  21. Jay says:
    November 16, 2016 at 9:35 pm

    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?

    Reply
    1. Jörgen Nilsson says:
      November 23, 2016 at 1:24 pm

      Hi,
      No Cdrive? which drive do you deploly the OS to?

      /jörgen

      Reply
  22. JagoWu says:
    February 23, 2017 at 10:00 pm

    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)

    Reply
    1. Rossm says:
      July 26, 2022 at 11:33 am

      thank you so much, 21h2 this stopped working for us. Your fix to our script was flawless.

      Reply
  23. Colton says:
    April 12, 2017 at 3:54 pm

    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?

    Reply
    1. Graham Riley says:
      April 29, 2019 at 5:34 pm

      @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.

      Reply
  24. Neil Natic says:
    May 22, 2017 at 8:09 pm

    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 🙁

    Reply
  25. Jose Espitia says:
    September 15, 2017 at 9:43 pm

    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/

    Reply
  26. Kurt Mitchell says:
    October 26, 2017 at 4:02 pm

    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?

    Reply
  27. v-juanm says:
    November 28, 2017 at 1:23 pm

    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\

    Reply
    1. c0nundrummer says:
      December 5, 2017 at 10:56 pm

      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?

      Reply
    2. c0nundrummer says:
      December 5, 2017 at 10:57 pm

      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

      Reply
  28. MelQ says:
    January 28, 2018 at 5:16 am

    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?

    Reply
    1. Jörgen Nilsson says:
      January 31, 2018 at 3:25 pm

      Hi,
      As it is only background pictures and still restricted to System, I thought it was ok.
      regards,
      Jörgen

      Reply
      1. Lucian says:
        March 5, 2018 at 6:10 pm

        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

        Reply
  29. Richard Grant says:
    February 1, 2018 at 12:47 pm

    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?

    Reply
  30. Roland says:
    February 5, 2018 at 10:44 am

    yes, you have to re-run the replacement

    Reply
  31. Roland says:
    February 5, 2018 at 10:45 am

    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?

    Reply
  32. Jason says:
    February 12, 2018 at 5:18 pm

    From where do the scripts run? On the GM to be captured?
    Thanks

    Reply
  33. Timothy says:
    March 21, 2018 at 6:19 pm

    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

    Reply
  34. Jeremy says:
    May 3, 2018 at 4:46 pm

    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

    Reply
    1. Alterator says:
      June 8, 2018 at 8:43 pm

      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.

      Reply
    2. Tim says:
      September 11, 2018 at 6:45 pm

      same. This worked well in v1607, but I recently upgraded my image to 1709 and I’m seeing the same behavior

      Reply
  35. Oliver says:
    July 25, 2018 at 12:19 am

    Is there a way to use this method to apply a TILED image regardless of resolution it picks?

    Reply
  36. Arjen says:
    August 26, 2018 at 10:07 pm

    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

    Reply
  37. Nick says:
    October 4, 2018 at 6:50 pm

    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.

    Reply
  38. Jesse says:
    January 17, 2019 at 3:20 pm

    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?

    Reply
    1. Jörgen Nilsson says:
      January 18, 2019 at 4:00 pm

      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

      Reply
  39. Pingback: Set custom wallpaper in Windows 10 during OSD with ConfigMgr - MSEndpointMgr
  40. Neil Clinch says:
    May 29, 2020 at 9:01 pm

    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

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • New settings in Intune Security Baseline Windows 11 24H2 -2504
  • Managing extensions in Visual Studio Code
  • Reinstall a required Win32app using remediation on demand
  • Administrator protection in Windows 11 – First look
  • Remediation on demand script – ResetWindowsUpdate
©2025 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT