I want to refresh wallpaper in Windows 7 from command line.
I'm setting wallpaper via reg.exe add
.
rundll32.exe user32.dll,UpdatePerUserSystemParameters
doesn't work (with 1,True
or 1,False
)
Requirements:
- It must refresh wallpaper immediately (no waiting)
- It must run from command line
- Default windows 7 command line is preferred. Writing a c++/VB/C# program is acceptable, but not as good as a default win7 cli solution.
Killing explorer is never a good idea, try this:
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
At least on Windows 7 64-bit, I found that the rundll32.exe command worked, but just not every time. I don't have a theory of why, but my workaround was a .cmd file that calls it a lot of times. It's not elegant but it works every time. In our environment, we are launching it in the background async and invisible, so the fact that it runs for about 80 seconds just doesn't matter.
:: Do your stuff to apply the background .reg settings first
:: Then run UpdatePerUserSystemParameters many times
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
timeout 1
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True
timeout 1
:: Etc. I have about 80 of them
Harder than I thought. Depending on your other needs you could eventually restart explorer.
taskkill /IM explorer.exe /F
explorer.exe
If you can call a program from the command line, you could also look at How to force Windows desktop background to update or refresh
reg add works better using .bmp files
this requires users to execute rundll32 multiple? times
try a simple rename conversion
picture.jpeg -> picture.bmp