How change walllpaper with Winbatch coding?

Started by pguild, November 16, 2022, 04:29:49 PM

Previous topic - Next topic

pguild

The wallpaper function no longer works, at least not for .jpg files. Is there a way to change wallpaper with Windows 10 or Windows 11?

I can easily change wallpaper manually, i just right click on an image and click Set as Background Image

But I want to programmatically change the wallpaper, say, every day or as a slideshow in yesteryear.
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

stanl

Found this as a batch process. If it works for you could be called from a WB script. Has to be run as administrator.


takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /reset
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

In my post I said that the WALLPAPER function in Winbatch does not work for me.
All my desired images for wallpaper are in jpg format not in bmp format.
It seems that the bmp format is required when using the WALLPAPER function.
When I use .jpg images with WALLPAPER, all I get is a nice black screen. 

I can easily manually use a .jpg image for wallpaper  if I simply right click on
the image and press b (for set as background).

Is there a workaround to automate a wallpaper change using Winbatch when using .jpg format?
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

pguild

Thanks,stani, for this batch process. I don't know how to use it for my purpose. My goal is to automatically and randomly pick from a list of .jpg images and change the wallpaper to something new everyday. The same way that an iPhone can change its wallpaper.

I can automate the manual process by going to a desired folder with .jpg images and moving the cursor over an image and right clicking and using sendkey to send "b" for set as background. But making sure I am clicking on an image is a challenge.  Any ideas? I appreciate you. Thanks!

Quote from: stanl on November 17, 2022, 03:40:33 AM
Found this as a batch process. If it works for you could be called from a WB script. Has to be run as administrator.


takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
icacls c:\windows\WEB\wallpaper\Windows\img0.jpg /reset
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
copy %~dp04k\*.* C:\Windows\Web\4K\Wallpaper\Windows

www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

td

Quote from: pguild on November 17, 2022, 08:35:29 AM
In my post I said that the WALLPAPER function in Winbatch does not work for me.
All my desired images for wallpaper are in jpg format not in bmp format.
It seems that the bmp format is required when using the WALLPAPER function.
When I use .jpg images with WALLPAPER, all I get is a nice black screen. 

I can easily manually use a .jpg image for wallpaper  if I simply right click on
the image and press b (for set as background).

Is there a workaround to automate a wallpaper change using Winbatch when using .jpg format?

The WallPaper function works with jpeg files on Windows 10/11. It has been tested with jpeg files on those platforms. It does require running the script/exe as an elevated admin just like the batch file does. If you do not execute the script as an elevated admin, you will likely just get a black desktop or something similar.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

How do I run a script or .exe in admin/elevated mode?
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer