Home » Questions » Computers [ Ask a new question ]

Schedule Windows XP wallpaper change without additional apps

Schedule Windows XP wallpaper change without additional apps

Ideally, I'd like to be able to do this through a batch file or VB script, so I can schedule it to run at different times of the day (dark wallpaper at night vs. light wallpaper at day).

Asked by: Guest | Views: 380
Total answers/comments: 2
Guest [Entry]

"You can use scheduled tasks along with this VBScript I just hacked together (this is for using multiple wallpapers and switching every few minutes for example):

Randomize
Set obshell = WScript.CreateObject(""Wscript.Shell"")
num = Int( ( 100 - 1 + 1 ) * Rnd + 1 )
CurrentDir = ""C:\Wallpapers\day\""
wallpaper = CurrentDir & ""Wallpaper"" & num & "".bmp""
obshell.RegWrite ""HKCU\Control Panel\Desktop\Wallpaper"",wallpaper
obshell.Run ""%windir%\System32\RUNDLL32.EXE user32.dll,
UpdatePerUserSystemParameters"",1,False
Set obshell = Nothing

Note: Wallpapers must be bitmaps. If you want to avoid more scripting to check system time periodically, you can use the same script for night and day just make a separate scheduled task and run it at the desired time at the desired interval. Make 2 folders, one for day wallpapers and one for night wallpapers, put a copy of the script in each. You'll need to change the 100 in line 3 to however many wallpapers are in each, and rename them to Wallpaper1, Wallpaper2, etc for this script to work (or modify the name in the script). Also modify the CurrentDir value for each.

If you'd like to only use 2 wallpapers (set it to run every 59 minutes or so to ensure you don't miss an hour):

Set obshell = WScript.CreateObject(""Wscript.Shell"")
CurrentHour = Hour(Now)
If CurrentHour = 8 Then
wallpaper = ""C:\Wallpapers\day.bmp""
ElseIf CurrentHour = 20 Then
wallpaper = ""C:\Wallpapers\night.bmp""
Else
WScript.Quit(0)
End If
obshell.RegWrite ""HKCU\Control Panel\Desktop\Wallpaper"",wallpaper
obshell.Run ""%windir%\System32\RUNDLL32.EXE user32.dll,
UpdatePerUserSystemParameters"",1,False
Set obshell = Nothing"
Guest [Entry]

"Here is a small VBS program ""ready to be used"": it gathers all those commands (selection of a random picture file in a directory using the ""Randomize"" VBS command + refresh the Windows wallpaper with it using ""UpdatePerUserSystemParameters"" + update the Windows ""WallpaperStyle"" registry).

And it works with .JPG picture files (not only with .BMP files), which is quite convenient...

The VB script source code is described at http://sites.google.com/site/sharerandomwallpapers/
Thanks."