Change to a new desktop wallpaper weekly [duplicate]
Based on this answer, something like the below code should work.
Option Explicit
Dim wsh : Set wsh = WScript.CreateObject("WScript.Shell")
Dim count, wallpaper
' Path to wallpapers, excludes number and ".png" extension
wallpaper = "C:\path\to\wallpaper\"
' Get current number of wallpaper
count = wsh.RegRead("HKCU\Software\WallpaperRotate\Count")
' Add one to it
count = count + 1
' Roll around if it's bigger than 999
If count > 999 Then count = 0
' Set wallpaper in registry
wsh.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpaper & count & ".png"
' Trigger wallpaper to be displayed
wsh.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
' Save latest number of wallpaper
wsh.RegWrite "HKCU\Software\WallpaperRotate\Count", count, "REG_DWORD"
Set wsh = Nothing
Some points to note:
- This should be saved as a vbscript file (with
.vbs
extension) and put it somewhere where you can access it - Create a DWORD called
HKCU\Software\WallpaperRotate\Count
with the value0
. - Change the
999
to the correct maximum number before you want it to roll back to displaying0.png
- Change the wallpaper path to correctly point to the folder of your pictures (as
C:\path\to\wallpaper\
wont be valid). Make sure that you include the trailing\
- This script assumes that every wallpaper is PNG format, if that's not the case then you either need to make them PNG or modify the code
- This script assumes that none of the files are prefixed with a
0
, so18.png
and not018.png
. If that isn't the case, you'll need to rename the files or modify the code - Double-click the script and, if it works, your wallpaper will be rotated
- Once it's working, schedule this script to run however frequently you want the wallpaper to be rotated