automation - Why does this small vbscript to change desktop background work intermittently, not all the time? -
a small vbscript in order change desktop background automatically, practically demo purposes:
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" msgbox "ok1" swallpaper = "c:\users\utsav\pictures\336180.png" elseif currwallpaper = "c:\users\utsav\pictures\336180.png" 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 system know change oshell.run "%windir%\system32\rundll32.exe user32.dll,updateperusersystemparameters", 1, true msgbox "done"
this script works intermittently, i.e. on executing command line change background once in 4-5 attempts. ideas explaining reason behaviour welcome.
Comments
Post a Comment