6

What I want is to programatically change Desktop Wallpaper every few hours. I'm using a batch file (.bat) and don't want to use other languages or programs, just the pre-installed stuff with Windows XP. I've already made my script that will modify values in the Registry

reg add "HKCU\Control Panel\Desktop" /v Wallpaper /d "C:\Pictures\picture1.jpg"

The problem is that the script is not taking effect in real time even with this command:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

I need to reboot first for it to take effect.

If I'm going to use Display Properties, it'll show at once. What I've noticed is that changes will take effect real time if it's a .bmp file and not for .jpg images.

Second option is to convert JPG to 24-bit BMP files (to look exactly the same, but will triple the file size), but I'm hoping a better way.

I've already Googled things but no avail. I hope you (the helpful reader) can post any .bat or even .vbs script to change Desktop Wallpaper instantly with JPG pictures. I hope there's an answer without installing other apps or scripts.

1

2 Answers 2

3

if i'm going to use Display Properties, it'll show at once. what i've noticed is that changes will take effect real time if it's a .bmp file and not for .jpg images.

That's because Windows does not support anything but bitmaps for the wallpaper (yes, even in Windows 7).

When you set a jpeg, gif, png, etc. as the wallpaper, Windows first converts it to a bitmap, saves it to a temporary file, and sets the wallpaper to that file (in Windows 7 the filename is more indicative of this):

In Windows XP: %appdata%\Microsoft\Internet Explorer\Wallpaper1.bmp
In Windows 7:  %appdata%\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg

So I'm afraid that you will indeed need to first convert it to bitmap.

5
  • yup. the full path is %USERPROFILE%\Local Settings\Application Data\Microsoft\Wallpaper1.bmp. the pre-installed wallpapers are JPG but then converted to BMP .. so Synetech no chance for pure JPG then?
    – itagomo
    Jun 27, 2012 at 15:12
  • I'm afraid not; Explorer just doesn't support compressed graphic files for wallpaper. Like I said, even Windows 7 converts the wallpapers to bitmap. (Don't ask me why they did it that way; I can't imagine there would be a practical performance issue since a compressed graphic file should only need to be decoded once per boot, when the desktop is first created.)
    – Synetech
    Jun 27, 2012 at 15:16
  • 1
    @Synetech - There are many things that can cause Windows 7 to redraw the Windows Desktop. The UAC prompt for instance, the desktop you see when the screen goes gray is a screenshot, when you hit accept/cancel the desktop is redrawn.
    – Ramhound
    Jun 27, 2012 at 15:19
  • nice .. thanks for making it clear .. I'm gonna have to find a script (vbs maybe) that'll convert JPG to BMP in the way the Desktop Properties does it real time .. but I'll mark you as the right answer and edit my post soon after doing some research ..
    – itagomo
    Jun 29, 2012 at 1:10
  • @Ramhound, I don't understand what your point is. None of those actions cause Explorer to re-read the file. Explorer only decodes the graphic file one time on boot up, then stores the data in memory. When you do something to cause the desktop to be redrawn, it does not re-read the file, it just uses the wallpaper data that it already has in memory. Frankly, I don't think it even re-reads the file if you restart Explorer (the wallpaper remains in place when you do so).
    – Synetech
    Jun 29, 2012 at 17:01
1

Try restarting explorer, which will re-initiate the registry which may (not tested) change the background without needing to reboot.

To do this in batch

taskkill /im explorer.exe /f && explorer
2
  • thanks Bali C but no it didn't .. what i got is a blank Wallpaper ..
    – itagomo
    Jun 27, 2012 at 15:06
  • @itagomo Ah right, Synetech's answer looks promising, I didn't know it had to be bitmap.
    – Bali C
    Jun 27, 2012 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.