Author Topic: How change walllpaper with Winbatch coding?  (Read 206 times)

pguild

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
How change walllpaper with Winbatch coding?
« on: November 16, 2022, 04:29:49 pm »
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.

stanl

  • Pundit
  • *****
  • Posts: 1706
Re: How change walllpaper with Winbatch coding?
« Reply #1 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.
Code: [Select]

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

  • Tech Support
  • *****
  • Posts: 4208
    • WinBatch
Re: How change walllpaper with Winbatch coding?
« Reply #2 on: November 17, 2022, 06:47:04 am »
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
Re: How change walllpaper with Winbatch coding?
« Reply #3 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?

pguild

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
Re: How change walllpaper with Winbatch coding?
« Reply #4 on: November 17, 2022, 08:54:49 am »
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!

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

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

  • Tech Support
  • *****
  • Posts: 4208
    • WinBatch
Re: How change walllpaper with Winbatch coding?
« Reply #5 on: November 17, 2022, 01:11:14 pm »
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

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
Re: How change walllpaper with Winbatch coding?
« Reply #6 on: December 14, 2022, 01:24:51 pm »
How do I run a script or .exe in admin/elevated mode?