1

What I want to do is so that for example, on January 1, it sets the wallpaper to the 785.png, and on January 8 (or after 7 days) it sets it to the 786.png and so on.

I tried following this guide, but I realized that it was too time-consuming to do this again and again for hundreds of images.

If it is needed, I am on Windows 11.

Thank you.

Note: This is not the same question for the "set wallpaper depending on time of day". I want it to set NEW images, not loop across certain images.

ehn
  • 15
  • 4
  • 1
    Does this answer your question? [Changing wallpaper depending on time of day via script or batch file?](https://superuser.com/questions/436978/changing-wallpaper-depending-on-time-of-day-via-script-or-batch-file) You can edit the task schedule frequency in the answer provided, to fit your requirement. – spikey_richie Nov 29 '21 at 16:21

1 Answers1

1

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 value 0.
  • Change the 999 to the correct maximum number before you want it to roll back to displaying 0.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, so 18.png and not 018.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
Richard
  • 5,831
  • 9
  • 44
  • 73
  • Thank you for the great answer! Although I'm a bit confused on the registry part. Do I make a folder named "WallpaperRotate" and make a new DWORD, name it "Count" and set it to 0? Or do I make a folder named "Count" and make a DWORD there? – ehn Nov 29 '21 at 17:18
  • @ehn In the registry, although they look like folders, they are called keys. So make a new key under `HKCU\Software` called `WallpaperRotate`, click on that, right click on the right hand pane and create a new DWORD called `Count` and it'll be set automatically to `0`. Sorry, I probably should have put something in the code to automatically create it if it didn't already exist. – Richard Nov 29 '21 at 17:34