Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
UpdatePerUserSystemParameters will not work with rundll32. –  grawity Jun 27 '12 at 15:49
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '12 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 '12 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 '12 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 '12 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 '12 at 17:01
add comment

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
share|improve this answer
    
thanks Bali C but no it didn't .. what i got is a blank Wallpaper .. –  itagomo Jun 27 '12 at 15:06
    
@itagomo Ah right, Synetech's answer looks promising, I didn't know it had to be bitmap. –  Bali C Jun 27 '12 at 15:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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