# Changing wallpaper depending on time of day via script or batch file?

I want to have 2 different wallpapers that change according to time of day (6 and 22 hours respectively) and only want to display the night one after 22 hours and the day one only after 6 hours and until 22 hours.

I didn't find a program that can do this after a standby, so I thought it should be easy to realize with the task scheduler running a script. Now the question is not only how to realize such a script, but also if the script should include the time checking or the task scheduler. I'm not sure what would work better with long times of the PC being in standby.

I tried a few scripts already from similar questions and hoped I could modify to them to my needs, but they didn't work at all.

Anyone able to help me? TIA.

-

This is actually very simple:

1. Right-click on the desktop background
2. Select "Personalize"
3. Click "Desktop background"
4. Drag and drop images into the box or select "Browse" and find the image(s)
5. Check both images make sure the morning one is first
6. Wait until 12:00 AM and select "Change image every 12 Hours"
7. Enjoy!
-
This is such an elegant trick! –  aalaap Apr 21 '14 at 4:27

Use the task scheduler and create a VBscript to change the wallpaper. Create a script for each wallpaper you intend to use.

dim shell
Set shell = WScript.CreateObject("WScript.Shell")
wallpaper = "C:\path\to\wallpaper.jpg"
shell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpaper
shell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True


Save the file as something.vbs and add it to the task scheduler, and voila! You got it all working.

It was also mentioned that it wouldn't change wallpaper if you've had your computer shut down at the time it should change. This is wrong, as the task can be set to run on the first boot after the selected time, so it will be set once you start the computer even if it was off during the time it should have changed. To set this up, go to the specific tasks properties and into the settings tab. Tick the second box in the window and off you go.

This script works perfectly for me in Windows 8. Please note how I modified the original script a bit to make the script shorter.

-

Everytime I see someone asking about do something on specific time or periodically on Windows, back me the ideia of using Windows Task Scheduler.

To do what you intend to do, you should create two taks, each one of them scheduled to execute one script or command to change from one to another wallpaper at the specific time that you want to. These commands should be able to automatically change your Windows wallpaper by itself, and the easiest way to do that is using Windows Registry. Here you can find HOWTO: Change the Desktop Wallpaper with the folowing registry key:

HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper

So, create your tasks setting the values to your registry and you will be able to change it automatically without needing to install any third-part apps.

-
Thanks, but that requires a restart, but it needs to apply instantly. I also tried that program already. It cant do what I want, because it wont change the wallpaper from say, night to day, if the PC missed a time to switch because it was in standby for example. –  Patrick Jun 15 '12 at 18:03
That doesn't help him at all - hence what I wrote in my post, it requires restart or log out and login to make the changes, thus not automatic. –  PnP Jun 16 '12 at 10:10
You're actually pretty close, you just need to update the system parameters afterwards. Take a look at my answer. –  Time Sheep Apr 17 '13 at 18:00

I had been meaning to do this for quite a bit, then came back across the topic while tweaking the configuration back to the way I like it, after a OS reinstall.

After looking into the project I found the slide show configuration file;(%APPDATA%/Microsoft/Windows/Themes/slideshow.ini). This file contains a line "ImagesRootPIDL=" that, after a bit of googling, indicates that the following big string of letters, numbers and symbols is in infact, a "uuencoded PCIDLIST_ABSOLUTE" apparently this is a way to locate a directory in windows at a lower level than using a path.

Anyway long story short it looks as though this file changes when an image is added to the dir for the slideshow or when the slide show is changed to a new dir. So my solution was to write a batch file to twice a day, depending on the %TIME% variable, copy the .ini for each of my slideshows to my configuration folder and append them with day or night then overwrite the .ini file in the themes folder with the appropriate slideshows .ini file.

The one downside of my solution is that, I now have a batch file running all the time, though I guess a scheduled task would be a better implementation and take care of that problem, I like to build things that only really interact with themselves. So far this hasn't needed any restart, of the computer or explorer to switch between slideshows, it just rolls over to the next slideshow after the time between slides is over. I haven't tried to make it fail yet, but running it for two weeks seems enough of a debug period to me.

I'm rather new to the windows OS, so my apologies if this has too many obvious statements in it, or is easily done by clicking a few times. I figure this kind of thing is the fastest way to learn the inner workings of the OS, though I think I could have wrote this in about five lines in a linux bash script rather than the forty some odd line batch colossus.

-

Sadly I don't think there is anything built into Windows that would allow you to do this without needing to actually log out and log back in. Since Wallpapers can be controlled via the registry, you could construct a batch file to modify the registry entry - but changes to the wallpaper itself wouldn't be seen until you log out and back in. You could try a 3rd party app such like: http://download.cnet.com/Automatic-Wallpaper-Changer/3000-2336_4-10560884.html

Hope this helps.

-