为什么这个用于更改桌面背景的小vbscript会间歇性工作,而不是一直工作?

为什么这个用于更改桌面背景的小vbscript会间歇性工作,而不是一直工作?,vbscript,automation,registry,scheduled-tasks,Vbscript,Automation,Registry,Scheduled Tasks,一个小的VBscript,用于自动更改桌面背景,实际上用于演示目的: dim wshShell dim sUserName Set wshShell = WScript.CreateObject("WScript.Shell") Set oShell = CreateObject("WScript.Shell") currWallPaper = oShell.RegRead("HKCU\Software\Microsoft\InternetExplorer\Desktop\General\

一个小的VBscript,用于自动更改桌面背景,实际上用于演示目的:

dim wshShell 
dim sUserName
Set wshShell = WScript.CreateObject("WScript.Shell") 
Set oShell = CreateObject("WScript.Shell") 
currWallPaper = oShell.RegRead("HKCU\Software\Microsoft\InternetExplorer\Desktop\General\Wallpap erSource")
If currWallPaper = "C:\Users\Utsav\Pictures\493889.png" Then
msgbox "OK1"
sWallPaper = "C:\Users\Utsav\Pictures\336180.png"
ElseIf currWallPaper = "C:\Users\Utsav\Pictures\336180.png" Then
sWallPaper = "C:\Users\Utsav\Pictures\1920-1080-278658.png"
Else
sWallPaper = "C:\Users\Utsav\Pictures\493889.png"
End If

' update in registry 
 oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
' let the system know about the change 
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
msgbox "done"
此脚本仅间歇工作,即从命令行执行时,它将在大约4-5次尝试中仅更改一次背景。任何解释这种行为原因的想法都是非常受欢迎的