Change background of a Windows 7 machine using Registry

Navigate to

HKEY_CURRENT_USER\Control Panel\Desktop

and change Wallpaper key value to the full path of your image.


I know this is an old tread, and Windows 7 is an OS fast becoming obsolete. But for the occasional user: I have dealt with this for years in my shop. I am close enough to IT to have certain privileges on my laptop, but not close enough to stop then making stupid GPOs which - of course - affects me as well.

On XP I am certain, on Windows 7 this is just an inspiration: This kind of changes to Registry will not take effect until you reboot the system! And since you try to circumvent a GPO, this equals "mission impossible" in many situations. There are, however, a way to force an update of the Registry to be applied without rebooting...

The thing is: You don't need to reboot - you need to flush the cashe of registry settings - which is a part of a reboot.

Solution (on XP at least):

@echo off
call :quiet>nul 2>&1
goto :EOF
:quiet
:: Configure Wallpaper (command prompt method works only with bmp files)
REG ADD "HKEY_CURRENT_USER\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\WINDOWS\Web\Wallpaper1.bmp" 
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 1
:: Make the changes effective immediately (only XP-compatible)
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

This works (worked) well for me on my XP machine, the trick being the last line: Execute "user32.dll,UpdatePerUserSystemParameters" as part of the bat-file. This takes the place of a "reboot". :-)

I put this in the Start folder, and added a shortcut key combination to the bat file: This way, my pc started with my own wallpaper, and when the GPO refreshes a couple of times during the day, I hit the shortcut key, and get my preferred view back (Which is infinitely prettier than the "black screen of depression" which is company stock) ;-)

I haven't got around to fix this on my new laptop (running Win 7) yet, but I guess someone out there can get inspired by this (XP) behavior and research further.


For those of you out there still dealing with XP boxes, I leave my previous answer intact.

However, I can now share an approach to solve the problem on a Windows 7 box:

  1. As I said before, you don't want to reboot the pc, because you are
    battling a Group Policy which is enforced on reboot (and in my
    personal case, every few hours during the day). However, changes to
    the registry need a flush of cashed settings before they become
    active. A reboot does that.

We need to find another way of accomplishing the target: "change-background-of-a-windows-7-machine..." - I skip the "using-registry" part, because I don't think it is possible, and frankly, I don't think it is the right approach on Windows 7! It was on XP - as I have stated in my previous answer.

The magic word now is "Themepack" - and the magic knowledge is: "It is executable!" What you need is an automated method of executing it and dealing with its embedded consequences.

  1. I use AutoHotkey version 1.1 (http://ahkscript.org/) for a number of things on my laptop, and if you have the permissions necessary for running this program, you are good to go:
  2. (Assuming you do nothing else with AutoHotkey): Create a txt file, name it anything but give it an ".ahk" file name extension instead of ".txt", and save it to the Startup folder ("C:\Users\ insert your username \AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" in my case). Now it will run at every startup.

Edit the file using Notepad or similar tool: Insert these lines:

    ; Setting wallpaper on the desktop on Win 7 which is: Apply a Themepack!
    <^<+D::
     Run "C:\Laptop theme.themepack"  ; Apply your Themepack
     WinWait Personlige indstillinger ; Wait for the window to get focus (the appearance is mandatory on an "apply" command)
     WinClose                         ; Close the last found window
    return

Note that I not only run the code at Startup, I also attach a hotkey (LCTRL+LSHIFT+D), which executes this part of the script at will.

Note also the command line "WinWait": My system is Danish, so the title of my Personalization window is "Personlige indstillinger". You need to insert here the title of the window on your own system. Read AHK help files how to do so, if it isn't obvious enough for you to guess it right to begin with.

  1. Now, all which remains is to Personalize your Windows 7 Laptop once and for all (unless a Group Policy prevents you (users) from changing things, you can always change things). When you are satisfied, save the resulting Themepack on the path you gave in the script (i.e. "C:\Laptop theme.themepack"), and done.

  2. Note: If you can't save anything on "C:\" then you can put the themepack anywhere - including in your personal user folders. The advantage of this is that you keep the script even when IT department is changing your laptop - provided they care to backup your user folders. My personal taste is just to keep things short, and I don't like connecting to network shares during startup if I can help it. Which I can.