Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i've been searching online for a batch solution to change the desktop background of Windows 7 Ultimate 64 bits, and after several attempts, i could only get it to work once but never again...

I'm using this:

SET "str=C:\Users\Jorge\Dropbox\Photos\Wallpapers\1379362257639.jpg"
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /f /t REG_SZ /d %str%
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

On the "Costumize" window after i run that, the new background appears there, but Desktop won't refresh... why? Also, i confirmed registry key also changes to the path of the picture, and i've tried bmp extension.

The weird part is, if i run it multiple times, it finally randomly changes (to the correct image but randomly...) i don't know why?

Edit: It seems after 3rd/4th time running that same code, it finnaly changes.. ?

share|improve this question

2 Answers 2


SET "str=C:\Users...


SET str="C:\Users...


share|improve this answer
Well, that also works, i believe it is the same thing, the problem is, it doesn't always change at the first run of the batch file, i want to know why.. – SomeNickName Mar 13 '14 at 2:55
Well, i further searched and apparently i found out that this doesn't work properly in windows 7+... i don't really know how to use that API from a batch file, the example which was provided in there has the same effect on changing here.. – SomeNickName Mar 13 '14 at 3:13
As i see, the problem is only in refreshing the wallpaper, and as the RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters appears to not work properly, always needs multiple times (aproximately 4) to successfully refresh the desktop... As i can't find anything right now that solves the problem, apparently this is being rouding up since 09 – SomeNickName Mar 13 '14 at 3:32

I found i had no chance of accomplish this perfectly using only a batch file... as far my batch knowledge goes, so, i used to pinvoke the SystemParametersInfo function like this:

Const SPIF_SENDCHANGE As UInteger = &H2


Note: In this case, the image doesn't have to be bmp, i tested with jpg and it worked fine. In my case there's no problem using to accomplish this, hope i helped somebody ;).

share|improve this answer

Your Answer


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.