Introduction: Changing Windows Desktop Backgorund From Task Scheduler or Shortcut
The clip above shows usage of utility, which allows to change windows background form command line, batch file, desktop shortcut and (most important) from Task Scheduler. The program at the start is supplied as with path to image file or folder with images. When argument is the file name, this file is just set as background. When argument is the folder name, the program randomly picks file from there. The program keeps track of used files. Once used files are excluded from the selection. As soon as all files are taken from the folder the list is cleared up so next time all files again available for random selection. Having several folders allows to separate files by themes or by genres. In an example you see how it works with three themes:
- night life
Utility written in C++ language and compiled with help of MS Visual Studio Community Edition. It works on my home desktop (Windows 8.1) , my wife's laptop (Windows 7. Home Edition) and my office desktop (Windows 7 Enterprise Edition). This post examples taken from Windows 8.1
Step 1: Getting the Project and Its Files
The source code of the project is available at : bitbucket. Fill free to take it from here. How to work with bitbucket GIt repository is out of scope of this post. Just as tip: the easiest way would be to download whole project zip archive.
The program changes the background with function SystemParametersInfo. That function requires image in bmp format. To convert file from jpg to bmp format the project utilizes FreeImage library (dll). That library may be downloaded from here
Step 2: Adding the Project Dependecies
The zip archive with library should be put into the same folder where "jumbleview" project is set and unzipped there. After that you are ready to build the project with VS Studio. Again working with the studio is out of scope of this post. Juts in case the archive with pre-built jumbleview.exe exists in the Release folder of the project. But you will feel more confident if you inspect code (it is fairly short) to be sure there us no hidden traps and everything under your control. Feel free to use or modify code in way you like it. Just not forget to give credit to FreeImage library if you will ever publish your code. The 32-bit as well as header file and library for linker is located according to this path: .\FreeImage3170Win32Win64\FreeImage\Dist\x32
Step 3: Starting the Utility First Time
Here is utility usage printing. Normally I use only option "-s" (in that case console windows is not opened and background is changed quietly).
Step 4: Creating Folders and Folders Content
There is no any wizard to set up the program. But few manual steps are easy to do.
- Create dedicated folder and place jumblveiew.exe and FreeImage.dll there.
- Create at least one dedicated folder with images (files in "jpg" format).
Step 5: Testing Setup With Shortcut
- Select the "jumbleview.exe" with mouse, right click on it and within context menu open property box. See if you need to unblock the executable. That may be be the case if executable is not built on this machine.
- With context menu send the executable shortcut to the desktop
- Configure property of shortcut as shown by the example .
- Click on shortcut to see how the program works. If it does not work you may remove the option "-s", try again and see console printing. That may give you a clue what is wrong.
Step 6: Activating Task Scheduler
I normally use this program as task action of Microsoft Task Scheduler. To start Task Scheduler just start typing word "scheduler" inside the desktop search field. Scheduler will be among the first recommended choices. Choose it.
Step 7: Task Scheduler: Adding the Task
Add the new task to the schedule. Example shows looks of various from elements.
Step 8: Task Scheduler: Setting Triggers
Set new task triggers. I myself have this set:
- At log on;
- on workstation unlock;
- At particular time.
Step 9: Task Scheduler: Setting Action
And the last step is to fill out Action properties. It looks very alike to the properties of desktop shortcut at step 5.
That's it. Enjoy randomly changed background each time you log on into the system or unlock workstation. Or schedule notification when to go for lunch, leave the office or go to bed.