问题
I have a script that runs (without error) to change the desktop wallpaper. The only problem is that it doesn't change the wallpaper. The registry entry is changed appropriately, so that bits working. Just the reloading is not working.
:: Configure Wallpaper
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\Users\greynolds\AppData\Roaming\APOD Wallpaper\apod_wallpaper1.png"
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 2
:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
回答1:
UpdatePerUserSystemParameters is a undocumented function AFAIK
ReactOS defines it as: BOOL WINAPI UpdatePerUserSystemParameters(DWORD dwReserved,BOOL Enable)
That function definition means that it is not a function you can call with RunDll32 (You end up passing random parameters to the function)
回答2:
As of this writing (in my experience) setting up HKCU\Control Panel\Desktop
more often would not work.
The best solution is to call win32 api function SystemParametersInfoSetWallpaper
- it works every time. I found this powershell module/snippet to be quite helpful https://gallery.technet.microsoft.com/scriptcenter/Change-window-borderdesktop-609a6fb2
回答3:
Here how you call this function but better to use documented API:
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1 True
来源:https://stackoverflow.com/questions/5018828/why-does-this-batch-file-fail-to-change-the-wallpaper-windows-7