Why does Wallpaper.reg not do what its supposed to when added to a batch file?

1

Whenever I'm installing Windows on new devices there are a lot of changes to be made which cost a lot of time. So I wanted to make some scripts which do exactly that for me.

For the past few days I have been searching for registry keys I can create/change for basic settings for Windows 10 (changing desktop wallpaper, small tray icons, etc). I found some and also have created my own, which I then have added together into a batch script.

I don't have much experience with batch scripts, but I wrote one, which when its executed as administrator will 'take' the keys in the folder the script is in, write them to the paths, then stop explorer.exe to and start it again for the changes to be applied.

@echo off

reg import %~dp0TaskViewButton.reg
reg import %~dp0SearchboxTaskbar.reg
reg import %~dp0RemoveContacsFromTaskbar.reg
reg import %~dp0EnableAutoTray.reg
reg import %~dp0Wallpaper.reg
reg import %~dp0TaskbandFavorites.reg
reg import %~dp0TaskbandFavoritesChanges.reg
reg import %~dp0TaskbandFavoritesResolve.reg

taskkill /f /im explorer.exe
start explorer.exe

pause

When I executed the script every key was successful excluding DesktopWallpaper.reg. FOr DesktopWallpaper.reg I created a new key folder named System with this string value named Wallpaper in HKCU\Software\Microsoft\Windows\CurrentVersion\Policies as it was the only possibility that worked for me.
It worked until I exported and put it into that script. The only thing I added and changed to that .reg file was the name and a RGB value which should be the color of the wallpaper. This is what the file looks like:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"Wallpaper"="46 141 239"

The command prompt shows an error for that file. When I double click the .reg file it tells me that an error occured while trying to access the registry as sysadmin. And not only that, executing the script also changes the wallpaper to a solid black. When accessing Personalisation > Background in the settings it tells me *Some settings are hidden or managed by your organization.

I have done some research on this as well and have tried fixing it with gpedit.msc. Apparently when Windows changes some settings they should also be in the Group Policy Editor. I followed some tutorials, but none of them worked for me. Some rules which should be enabled there were 'not configured'.

Any kind of help would be appreciated.

Rin

Posted 2019-02-27T14:32:34.970

Reputation: 13

Question was closed 2019-03-13T16:42:13.193

2You never asked a specific Question – Moab – 2019-02-27T14:57:46.393

The title is supposed to be a specific question. – Rin – 2019-02-27T15:28:59.020

It is always better to also include it in the body of the question itself. – Moab – 2019-02-27T15:42:24.340

Answers

0

There are a few reasons why that particular registry change doesn't work:

  1. Restarting Windows Explorer (explorer.exe) does not update the background color, only the background image. Updating the background color requires logging out and logging back in.
  2. The keys you should probably be using are:

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Control Panel\Colors]
    "Background"="46 141 239"
    
    [HKEY_CURRENT_USER\Control Panel\Desktop]
    "WallPaper"=""
    
  3. The key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\Wallpaper seems to:

    • only accept local file paths—not colors or UNC paths.
    • override HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper.
    • restrict changing the wallpaper through Personalization -> Background.
    • require all \ be escaped as \\

Worthwelle

Posted 2019-02-27T14:32:34.970

Reputation: 3 556