Changing windows 7 wallpaper via an app or batch file

I've got a collection of pictures that I use for the wallpaper on a windows desktop.  It is set to move through the collection randomly at 30 minute intervals.

Occasionally I would like to change the wallpaper (as if the 30 minute interval had elapsed) at that instant.  I can go to the desktop, right click then in the context menu select 'Next esktop background'.  Now I sometimes find that a bit of work and would like to have an app/bat file on the desktop that would perform the same action.

What command / windows API is required to perform the same action as that context menu command ?
LVL 45
AndyAinscowFreelance programmer / ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantAuthor Commented:
context menu
Joe Winograd, Fellow&MVEDeveloperCommented:
Hi Andy,

Check out this thread:

I'm a huge fan of AutoHotkey, an excellent (free!) programming/scripting/keyboard macro language, so that's the solution I would use, although you may prefer one of the others. If you do like the AutoHotkey approach, note that there have been several forks of the original language and my preferred one now is AutoHotkey_L. It comes with a compiler that turns the AHK source code (plain text) into a stand-alone/no-install executable (an EXE file).

There is good documentation:

...including an alphabetical command and function index:

...a decent tutorial:

...and an active user forum:

Regards, Joe

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantAuthor Commented:
From the first link:
set WshShell = WScript.CreateObject("WScript.Shell")
        WshShell.SendKeys("^ ")
saved as a vbs file on the desktop.  Double click and it does the job.

Excellent, thanks.
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Jacques Bourgeois (James Burger)PresidentCommented:
The API to call is SystemParametersInfo, with SPI_SETDESKWALLPAPER (20) as the first parameter. Here is sample code in VB:

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uiAction As Integer, ByVal uiParam As Integer, ByVal pvParam As String, ByVal fWinIni As Integer) As Boolean



Open in new window

AndyAinscowFreelance programmer / ConsultantAuthor Commented:
@James - thanks but that isn't quite what I was asking for.  (Maybe it is something similar)
Joe Winograd, Fellow&MVEDeveloperCommented:
You're welcome. That VBS script is a clean, simple solution. Regards, Joe
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.