title: When I use a VBS script to change my wallpaper, I have to log off for changes to take effect
body: <p>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?</p>
  
  <p>I am running Windows 7 and am running code which will take a given path file, such as <em>a.jpg</em> or <em>a.bmp</em>, and replace the file at the location:</p>
  
  <p><em>C:\Users\Brad\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper.jpg</em></p>
  
  <p>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:</p>
  
  <pre><code>' Create explorer command file to toggle desktop window
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  sSCFFile= oFSO.BuildPath(oFSO.GetSpecialFolder(2), oFSO.GetTempName &amp;".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 """" &amp; sSCFFile &amp; """"
  WScript.Sleep 100
  .Sendkeys "{F5}"
  End With
  ' Delete explorer command file
  oFSO.DeleteFile sSCFFile
  </code></pre>