//
you're reading...
MDT, Windows

Changing default Windows 8.1 wallpaper during MDT Task Sequence

Changing a wallpaper should be a trivial task, shouldn’t it? All we need to do is to replace a file… This post walks you through hurdles you will stumble up and how to get through them.

Default Windows 8.1 wallpaper is stored in C:\windows\web\wallpaper\Windows directory and is called img0.jpg. However, you can’t just overwrite the file out of the box due to permissions – trying to do so will only return “Access denied” message. To get round that we first need to take ownership of the file and then grant Full Control to Administrators group (I am assuming that your Task Sequence is running using admin account). There are two handy commands that can do just that for us:

takeown /f C:\Web\Wallpaper\Windows\img0.jpg
icacls "C:\Web\Wallpaper\Windows\img0.jpg" /grant "Administrators":F

Having those permissions changed, we can now safely replace the the file:

xcopy /Q /R /Y custom_wallpaper.jpg C:\Web\Wallpaper\Windows\img0.jpg

In next step we point relevant registry key to our file (out of the box it will already be set to it anyway):

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /d "C:\windows\web\wallpaper\Windows\img0.jpg" /f

And now for the final obstacle. Typically for these changes to take effect, we would need to either log off or use a command to activate HKEY_CURRENT_USER changes. I have found both solutions bit unreliable (hit and miss results) if you don’t purge cached wallpaper first. This can be done by deleting TranscodedImageCache value and refresh settings using one of the methods mentioned above.

reg delete "HKEY_CURRENT_USER\Control Panel\Desktop" /v TranscodedImageCache /f
rundll32.exe user32.dll, UpdatePerUserSystemParameters

This will rebuild the cache using new wallpaper and changes will be applied immediately. So, for completeness our script turns into the following set of commands:

takeown /f C:\Web\Wallpaper\Windows\img0.jpg
icacls "C:\Web\Wallpaper\Windows\img0.jpg" /grant "Administrators":F
xcopy /Q /R /Y custom_wallpaper.jpg C:\Web\Wallpaper\Windows\img0.jpg
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /d "C:\windows\web\wallpaper\Windows\img0.jpg" /f
reg delete "HKEY_CURRENT_USER\Control Panel\Desktop" /v TranscodedImageCache /f
rundll32.exe user32.dll, UpdatePerUserSystemParameters

 

 

Discussion

2 thoughts on “Changing default Windows 8.1 wallpaper during MDT Task Sequence

  1. Ni post, but I have a question…
    At which level of the Task Sequence do you insert the script?
    Thanks!

    Like

    Posted by Gianluigi | 2016-05-05, 11:52

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Categories

%d bloggers like this: