2011-03-07 79 views
2

我写了一个小的vbs脚本来下载并更改当前用户壁纸的注册表。然而,它复制并做了改变,但壁纸不会改变...在下面的代码错误的任何想法?在Windows 7中更改壁纸

Option Explicit 
Dim WshShell, strValue, sleepTime, oFSO 

strValue = "C:\wallpaper.bmp" 
sleepTime = 30000 

Set oFSO = CreateObject("Scripting.FileSystemObject") 
oFSO.CopyFile "\\anspksnms1\OSD\Scripts\wallpaper\wallpaper.bmp", "C:\" 

Set WshShell = WScript.CreateObject("Wscript.Shell") 
WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strValue 
WScript.Sleep sleepTime 
WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False 

Set WshShell = Nothing 
+0

您是否尝试将“1,False”更改为“1,True”?其中一个答案中的代码使用True,http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_7/Q_26745508.html – Russell 2011-03-07 00:56:17

+0

另外,可能有一个原因是您正在使用VB脚本,但PowerShell可能会提供替代方案http://blogs.technet.com/b/heyscriptingguy/archive/2009/02/05/how-can-i-hide-my-desktop-wallpaper.aspx – Russell 2011-03-07 00:57:51

回答

0

我不是很多的vbscripter,但也许试试这个?

wshShell.run "cmd /c RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters", 1, True