为什么此批处理文件无法更改壁纸(Windows 7)

时间:2011-02-16 16:07:32

标签: windows-7

我有一个运行(没有错误)的脚本来更改桌面墙纸。唯一的问题是它不会改变壁纸。注册表项已适当更改,以便位工作。只是重装不起作用。

:: 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

3 个答案:

答案 0 :(得分:2)

UpdatePerUserSystemParameters是一个未记录的函数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(最后将随机参数传递给函数)

答案 1 :(得分:0)

在撰写本文时(根据我的经验),更频繁地设置HKCU\Control Panel\Desktop是行不通的。

最好的解决方案是调用win32 api函数SystemParametersInfoSetWallpaper - 它每次都有效。我发现这个powershell模块/代码段非常有帮助https://gallery.technet.microsoft.com/scriptcenter/Change-window-borderdesktop-609a6fb2

答案 2 :(得分:0)

如何调用此函数,但最好使用已记录的API:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1 True