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%Web4KWallpaperWindows will be used.
If the resolution used doesn’t match any of the above resolutions the default background %Windir%WebWallpaperWindowsimg0.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%WEBwallpaperWindowsimg0.jpg
takeown /f %WinDir%Web4KWallpaperWindows*.*
icacls %WinDir%WEBwallpaperWindowsimg0.jpg /Grant System:(F)
icacls %WinDir%Web4KWallpaperWindows*.* /Grant System:(F)
del %WinDir%WEBwallpaperWindowsimg0.jpg
del /q %WinDir%Web4KWallpaperWindows*.*
copy %~dp0img0.jpg %WinDir%WEBwallpaperWindowsimg0.jpg
copy %~dp04k*.* %WinDir%Web4KWallpaperWindows
takeown /f c:windowsWEBwallpaperWindowsimg0.jpg
takeown /f C:WindowsWeb4KWallpaperWindows*.*
icacls c:windowsWEBwallpaperWindowsimg0.jpg /Grant System:(F)
icacls C:WindowsWeb4KWallpaperWindows*.* /Grant System:(F)
del c:windowsWEBwallpaperWindowsimg0.jpg
del /q C:WindowsWeb4KWallpaperWindows*.*
copy %~dp0img0.jpg c:windowsWEBwallpaperWindowsimg0.jpg
copy %~dp04k*.* C:WindowsWeb4KWallpaperWindows
And the Powershell Script:
takeown /f c:windowsWEBwallpaperWindowsimg0.jpg
takeown /f C:WindowsWeb4KWallpaperWindows*.*
icacls c:windowsWEBwallpaperWindowsimg0.jpg /Grant 'System:(F)'
icacls C:WindowsWeb4KWallpaperWindows*.* /Grant 'System:(F)'
Remove-Item c:windowsWEBwallpaperWindowsimg0.jpg
Remove-Item C:WindowsWeb4KWallpaperWindows*.*
Copy-Item $PSScriptRootimg0.jpg c:windowsWEBwallpaperWindowsimg0.jpg
Copy-Item $PSScriptRoot4k*.* C:WindowsWeb4KWallpaperWindows
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.
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:WindowsWebWallpaperWindows 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:WindowsWeb4KWallpaperWindowsimg0_1366x768.jpg Access is denied.
takeown /f c:windowsWEBwallpaperWindowsimg0.jpg
takeown /f C:WindowsWeb4KWallpaperWindows*.*
icacls c:windowsWEBwallpaperWindowsimg0.jpg /Grant System:(F)
icacls C:WindowsWeb4KWallpaperWindows*.* /Grant System:(F)
del c:windowsWEBwallpaperWindowsimg0.jpg
del /q C:WindowsWeb4KWallpaperWindows*.*
copy %~dp0img0.jpg c:windowsWEBwallpaperWindowsimg0.jpg
copy %~dp04k*.* C:WindowsWeb4KWallpaperWindows
Any ideas what I am doing wrong? TIA
asked Nov 5, 2015 at 18:17
user1342164user1342164
1,42413 gold badges40 silver badges82 bronze badges
4
Use Powershell to change the wallpaper. First, create a function like this:
Function Set-WallPaper($Value)
{
Set-ItemProperty -path 'HKCU:Control PanelDesktop' -name wallpaper -value $value
rundll32.exe user32.dll, UpdatePerUserSystemParameters
}
Now call the function:
Set-WallPaper -value "path to wallpaper"
TeWu
5,5522 gold badges21 silver badges36 bronze badges
answered Nov 5, 2015 at 21:33
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:windowsWEBwallpaperWindowsimg0.jpg
icacls c:windowsWEBwallpaperWindowsimg0.jpg /reset
copy %~dp0img0.jpg c:windowsWEBwallpaperWindowsimg0.jpg
copy %~dp04k*.* C:WindowsWeb4KWallpaperWindows
should work (as long as it is being run by an Administrative account).
answered Sep 16, 2016 at 13:18
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}")
answered Jan 20, 2019 at 5:22
1
Below are fixes to what you provided above along with some recommendations.
At bottom solution to update wallpaper without a restart.
Error Produced: «ERROR: File or Directory not found.»
Error Producing Code: Takeown.exe /F «C:WINDOWSWeb» /R /D S
Fix: Takeown.exe /F «C:WINDOWSWeb» /R /D Y
Explanation: /D has to be followed by Y for yes or N for No.
Takeown has a bug and so no trailing backslash is allowed unless followed by a FileSpec/Wildcard token *
Non Error Producing Error: Administrator should be Administrators when adding Permissions with ICacls, unless you created a user name with the string ‘Administrator’, but follow what ElektroStudios stated above and use the current user.
Allowing the current user permissions to system files is not a good idea though because you are altering the security of your system. So your initial idea of allowing the administrators group permissions to these files is sound.
Scripting Style Error:
You shouldn’t delete the wallpaper files because you can barely get this script to work. Until then you should just try to accomplish tasks thru your script without ruining files on the Operating System. This is just a good habit when it comes to scripting, so you don’t ruin your computer or alter its security state. By changing the Wallpapers you could let a virus into your computer depending on where you get your wallpapers from.
Here is how to make the script work.
Taken from Rob Vanderwoude Script SetWallp.bat who credits Pete Smith for RUNDLL32 command to activate changes. http://www.robvanderwoude.com/sourcecode.php?src=setwallp_nt
Activate changes
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1 True
- Remove From My Forums
-
Question
-
I created a batch script to replace the default Windows 7 and 8.1 background image, («C:WindowsWebWallpaperWindowsimg0.jpg») with a custom image.
TAKEOWN.exe /F C:ProgramDataMicrosoftWindowsSystemData /R /A /D y TAKEOWN.exe /F "C:WindowsWebScreenimg100.jpg" /A TAKEOWN.exe /F "C:WindowsWebWallpaperWindowsimg0.jpg" /A cacls "C:WindowsWebScreenimg100.jpg" /T /G "Administrator":F /E cacls "C:WindowsWebWallpaperWindowsimg0.jpg" /T /G "Administrator":F /E cacls "C:ProgramDataMicrosoftWindowsSystemData" /T /G "Administrator":F /E cacls "C:ProgramDataMicrosoftWindowsSystemData" /T /G "SYSTEM":F /E del /F /Q C:ProgramDataMicrosoftWindowsSystemDataS-1-5-18ReadOnlyLockScreen_Z*.* del /F /Q "C:ProgramDataMicrosoftUser Account Pictures"*.dat xcopy /e /y C:UsersAdministratorDesktopWin8.1UserIcons*.* "C:ProgramDataMicrosoftUser Account Pictures" xcopy /e /y C:UsersAdministratorDesktopWin8.1LockScreen*.* "C:WindowsWebScreen" xcopy /e /y C:UsersAdministratorDesktopWin8.1Wallpaper*.* "C:WindowsWebWallpaperWindows"
This has been working fine for a while with no issues. Until I began to use BGINFO through GPO that drops the files and adds BGINFO to the Startup folder.
Now when a Windows 8.1 computer boots up, and a new user logs in, they get the custom background for a second, until BGInfo starts then they get the default desktop «color» instead, with BGInfo pasted on.
I checked Security permissions on the custom file, and a clean machine with the original file. No differences.
I’m now having the same problem in Windows 10.
Any ideas on how to troubleshoot this?
Thanks!
-Matt
There’s no place like 127.0.0.1
Answers
-
That seems to have done it. I added to the script to make this work going forward.
TAKEOWN.exe /F C:ProgramDataMicrosoftWindowsSystemData /R /A /D y TAKEOWN.exe /F "C:WindowsWeb4KWallpaperWindows*.jpg" /A TAKEOWN.exe /F "C:WindowsWebScreenimg100.jpg" /A TAKEOWN.exe /F "C:WindowsWebWallpaperWindowsimg0.jpg" /A cacls "C:ProgramDataMicrosoftWindowsSystemData" /T /G "Administrator":F /E cacls "C:ProgramDataMicrosoftWindowsSystemData" /T /G "SYSTEM":F /E cacls "C:WindowsWeb4KWallpaperWindows*.jpg" /T /G "Administrator":F /E cacls "C:WindowsWebScreenimg100.jpg" /T /G "Administrator":F /E cacls "C:WindowsWebWallpaperWindowsimg0.jpg" /T /G "Administrator":F /E del /F /Q C:ProgramDataMicrosoftWindowsSystemDataS-1-5-18ReadOnlyLockScreen_Z*.* del /F /Q "C:ProgramDataMicrosoftUser Account Pictures"*.dat xcopy /e /y C:UsersAdministratorDesktopWin10VMUserIcons*.* "C:ProgramDataMicrosoftUser Account Pictures" xcopy /e /y C:UsersAdministratorDesktopWin10VMWindowsWeb4KWallpaperWindows*.* "C:WindowsWeb4KWallpaperWindows" xcopy /e /y C:UsersAdministratorDesktopWin10VMWindowsWebScreen*.* "C:WindowsWebScreen" xcopy /e /y C:UsersAdministratorDesktopWin10VMWindowsWebWallpaperWindows*.* "C:WindowsWebWallpaperWindows" cacls "C:WindowsWeb4KWallpaperWindows*.jpg" /T /G "Administrators":F /E cacls "C:WindowsWebScreenimg100.jpg" /T /G "Administrators":F /E cacls "C:WindowsWebWallpaperWindowsimg0.jpg" /T /G "Administrators":F /E cacls "C:WindowsWeb4KWallpaperWindows*.jpg" /T /G "SYSTEM":F /E cacls "C:WindowsWebScreenimg100.jpg" /T /G "SYSTEM":F /E cacls "C:WindowsWebWallpaperWindowsimg0.jpg" /T /G "SYSTEM":F /E cacls "C:WindowsWeb4KWallpaperWindows*.jpg" /T /G "Users":R /E cacls "C:WindowsWebScreenimg100.jpg" /T /G "Users":R /E cacls "C:WindowsWebWallpaperWindowsimg0.jpg" /T /G "Users":R /E
-Matt
There’s no place like 127.0.0.1
-
Marked as answer by
Thursday, October 1, 2015 9:44 PM
-
Marked as answer by
Join
- Home
- Windows
- Active Directory & GPO
- How-tos
Last Updated:
May 10, 2013
1 Minute Read
-
Spice
-
Reply (2)
-
Subscribe
-
Share
Opens a new window
-
Facebook
Opens a new window -
Twitter
Opens a new window -
Reddit
Opens a new window -
LinkedIn
Opens a new window
-
- Spiceworks General Support |
- Microsoft Exchange |
- Windows 7 |
- General Windows |
- Active Directory & GPO
Sign Up
Load More