VBS script not running every time

Akersar

Distinguished
May 31, 2010
7
0
18,510
0
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
 

Jaime3d

Honorable
Dec 3, 2013
4
0
10,520
1
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.
 

Jaime3d

Honorable
Dec 3, 2013
4
0
10,520
1
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.
 

Akersar

Distinguished
May 31, 2010
7
0
18,510
0


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.
 

Akersar

Distinguished
May 31, 2010
7
0
18,510
0


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

Jaime3d

Honorable
Dec 3, 2013
4
0
10,520
1

Akersar

Distinguished
May 31, 2010
7
0
18,510
0

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.
 
Thread starter Similar threads Forum Replies Date
H Apps General Discussion 1
ExtreamChaozZ Apps General Discussion 6
D Apps General Discussion 5
V Apps General Discussion 1
D Apps General Discussion 3
packersfan036 Apps General Discussion 4
S Apps General Discussion 1
G Apps General Discussion 1
SyncroScales Apps General Discussion 4
A Apps General Discussion 1
Tom Waller Apps General Discussion 2
tarmiricmi Apps General Discussion 5
C Apps General Discussion 6
T Apps General Discussion 5
R Apps General Discussion 2
C Apps General Discussion 9
K Apps General Discussion 4
A Apps General Discussion 2
JoeMomma Apps General Discussion 6
G Apps General Discussion 2

ASK THE COMMUNITY