【发布时间】:2014-08-24 20:11:24
【问题描述】:
当我使用 VBS 脚本更改我的壁纸时,我必须注销才能使更改生效。我怎样才能做到这一点,这样我就不必在运行脚本后注销?
我正在运行 Windows 7,并且正在运行将采用给定路径文件的代码,例如 a.jpg 或 a.bmp,并将文件替换为地点:
C:\Users\Brad\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg
我列出了我找到的 VBS 文件的代码,它应该刷新我的活动桌面。它像脚本一样闪烁,但它不会更新我的壁纸:
' Create explorer command file to toggle desktop window
Set oFSO = CreateObject("Scripting.FileSystemObject")
sSCFFile= oFSO.BuildPath(oFSO.GetSpecialFolder(2), oFSO.GetTempName &".scf")
With oFSO.CreateTextFile(sSCFFile, True)
.WriteLine("[Shell]")
.WriteLine("Command=2")
.WriteLine("[Taskbar]")
.WriteLine("Command=ToggleDesktop")
.Close
End With
' Toggle desktop and send F5 (refresh)
With CreateObject("WScript.Shell")
.Run """" & sSCFFile & """"
WScript.Sleep 100
.Sendkeys "{F5}"
End With
' Delete explorer command file
oFSO.DeleteFile sSCFFile
【问题讨论】:
-
我认为你有 2 个选项。使用像SetWallpaper.exe 这样的第三方实用程序,或者你可以使用像this 这样的发送键来发挥作用
标签: shell vbscript windows-7 wallpaper