VB Script to change the desktop wallpaper

Below is the script to change your desktop wallpaper. You just need to modify the script to point to the location where the 'wallpaper is located.

You can then include this script in your Domain's Group Policy's login or startup script.

 

' ----------------------------Script to change Desktop Wallpaper-----------------------------------------

dim wshShell
dim sUserName

Set wshShell = WScript.CreateObject("WScript.Shell")
sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = "C:\Users\eskonr\Pictures\Nice-Windows-7.jpg"

' update in registry
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper

' let the system know about the change
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

msgbox "done"

 

You will have to change the bold letter (image file) with your image file path.

5 Responses to "VB Script to change the desktop wallpaper"

  1. When I run it the first time it changes, but when I run it a second time with a different wallpaper, it doesn't change. Also, when you do it, you have to restart Explorer.

    Reply
    1. can you check the registry for wallpaper patch in HKEY_CURRENT_USER\Control Panel\Desktop\?is it set correctly ?

      Regards,
      Eswar

      Reply

Post Comment