When I use a VBS script to change my wallpaper, I have to log off for changes to take effect. How can I make it so I don't have to log off once I run my script?
I am running Windows 7 and am running code which will take a given path file, such as a.jpg or a.bmp, and replace the file at the location:
C:\Users\Brad\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg
I have listed the code for a VBS file that I found and it is supposed to refresh my active desktop. It flashes like the script works, however it does not update my wallpaper:
' 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