VBS script not running every time

Status
Not open for further replies.

Akersar

Distinguished
May 31, 2010
7
0
18,510
Hey, so pretty much, it is as the title states. I have set up a VBS script and it does run but not always. I have to click on it multiple times for it to work. It a script to set up a wallpaper as a background and I have it set with a task scheduler so that it changes wallpapers in relation to the time of the day.
Here is one of the 9 scripts (one for each wallpaper):

dim shell
Set shell = WScript.CreateObject("WScript.Shell")
wallpaper = "C:\Users\Akersar\Pictures\asd\em.jpg"
shell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpaper
shell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

So yeah, it does run, but not every time I double-click on it. Any insights or solutions? I ask you friends!

Thank you in advance
 
Solution
When you click on it and it doesn't work, look at the registry at HKCU\Control Panel\Desktop\Wallpaper. Does it update there? That could give you a clue as to where it's hanging up.
When you click on it and it doesn't work, look at the registry at HKCU\Control Panel\Desktop\Wallpaper. Does it update there? That could give you a clue as to where it's hanging up.
 
Solution


EDIT: I have found the registry line for the wallpaper and I see and have confirmed that it changes in the registry, but it does not change the actual background.
 


It doesn't seem to eventually change (waited for 8 mins approximately). Must I wait longer?
 

It seems to be a fix for him, but I'm not sure how to set this up. Do I just replace my other code with this one and save it as VBS again? I get a Syntax error when I try to start it.
 
Status
Not open for further replies.