Script to Change Desktop Background

By Kevin Walker

Most users don't realize it, but Microsoft installs a copy of their Visual Basic Script language on every Windows computer. This simple but powerful language makes it possible to automate nearly every task a user or administrator will need to perform on a system, such as change the desktop background.

Text Editor

Creating a Visual Basic Script is easy: all you need is a simple text editor such as Windows Notepad. However, instead of saving the file with a name that ends in ".TXT," the file must be saved with a name ending in ".VBS."

The Script

Paste the following into a text editor:dim shelldim userSet shell = WScript.CreateObject("WScript.Shell")user = shell.ExpandEnvironmentStrings("%USERNAME%")Set fso = CreateObject("Scripting.FileSystemObject")windowsDir = fso.GetSpecialFolder(0)wallpaper = "c:\wallpaper.jpg"shell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpapershell.Run "%windowsDir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, TrueChange the file "c:\wallpaper.jpg" to the path and filename of the desktop background you would like to use.

How to Run

To run the script, simply save it with the file extension .VBS. Then, double-click its icon on your Desktop with your mouse as you would to start any other program.