Solved Automatically set Spotlight image as background on Windows 10


LesFerch

Well-known member
Power User
VIP
Local time
1:58 PM
Posts
618
Location
Pleasantville, NY, USA
OS
Windows 10/11
I went looking for an app that would automatically set the background to the Spotlight image (on Windows 10) and found Dynamic Theme. Mentioned here:


However, I'm disappointed that it doesn't use the same image that is currently being used for the lock screen. Instead, it downloads a random Spotlight image on its own. While there's nothing wrong with that, I want my background to be set to the same image as the lock screen, as it is on Windows 11.

I'm going to write my own tool to do that, unless someone tells me it's already been done. So that's my question. Is there a tool out there that will set the Windows 10 background to the Spotlight lock screen image?
 
Last edited:

My Computer

System One

  • OS
    Windows 10/11
    Computer type
    Laptop
    Manufacturer/Model
    Acer
Technically, there could be multiple lockscreen images, but OK whatever...

Code:
# https://www.joseespitia.com/2017/09/15/set-wallpaper-powershell-function/

Function Set-WallPaper($Image) {
 
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
 
public class Params
{
    [DllImport("User32.dll",CharSet=CharSet.Unicode)]
    public static extern int SystemParametersInfo (Int32 uAction, Int32 uParam, String lpvParam, Int32 fuWinIni);
}
"@
 
    $SPI_SETDESKWALLPAPER = 0x0014
    $UpdateIniFile = 0x01
    $SendChangeEvent = 0x02
 
    $fWinIni = $UpdateIniFile -bor $SendChangeEvent
 
    $ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni)
 
}

$SID = ([System.Security.Principal.WindowsIdentity]::GetCurrent()).User.Value
$LockScreenFile = Get-ChildItem "C:\ProgramData\Microsoft\Windows\SystemData\$SID\ReadOnly" -Recurse -File | select -First 1

Set-WallPaper($LockScreenFile.FullName)
 

My Computer

System One

  • OS
    Windows 7
Les, your lockscreen images should be located in one of the folders at C:\ProgramData\Microsoft\Windows\SystemData\

You will need to take ownership of that folder to get into it, but from there you could possible write a script file to rotate the image files at will, set them as the Desktop image or use them for whatever purpose you like.

Please let me know what you come up with, I'd be interested to see it :-)

Of course @garlin's script seems to have it covered ... lol
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin
Actually you don't need to change any permissions, if you're only parsing your own SID's folders. My posted script doesn't need special permissions to read the folder.
 

My Computer

System One

  • OS
    Windows 7
Yeah, I saw your script AFTER I had posted and I only offered a manual way to get to the images.

Your solution is much better though ... lol
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin
@trumpy81, I read the Superuser discussion about requiring takeown, but they're wrong.

You can have an intermediate folder in the path which only allows execute but not read permission. If you know the child folder's name past that level, then read permission isn't required until you get to the very last folder in the full path.
 

My Computer

System One

  • OS
    Windows 7
@garlin Not bad. Not bad at all.

I see that file location contains the current image fill-adjusted for my monitor's resolution. Whereas, %LocalAppData%\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets contains the last three images in their original 1920x1080 (landscape) and 1080x1920 (portrait) formats. I was thinking of writing a tool that would display the current image on the primary monitor and the next newest ones on the second and third monitors respectively (not sure what I'd do with 4 or more monitors).

The script above uses SystemParametersInfo, so it will display the same image on all monitors. The IDesktopWallpaper interface has to be used to change the wallpaper on individual monitors. I've done that already in my WallP app, so I have most of the pieces already.

In the meantime, I'll definitely use that script. Thank you!
 

My Computer

System One

  • OS
    Windows 10/11
    Computer type
    Laptop
    Manufacturer/Model
    Acer
@trumpy81, I read the Superuser discussion about requiring takeown, but they're wrong.

You can have an intermediate folder in the path which only allows execute but not read permission. If you know the child folder's name past that level, then read permission isn't required until you get to the very last folder in the full path.
Exactly! The proof is in the testing. The script can be run in a normal PowerShell window.
 

My Computer

System One

  • OS
    Windows 10/11
    Computer type
    Laptop
    Manufacturer/Model
    Acer
Yeah, my knowledge of Power Shell is somewhat limited and the only way I could think of, on short notice, was to access the folder directly.

The script is a much more elegant solution, but out of my scope ATM. I am learning though ... lol
 

My Computer

System One

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    Ryzen 9 3900X
    Motherboard
    ASUS ROG Strix X570-E Gaming
    Memory
    G-Skill RipjawsV F4-3600C18 (16GB x 2)
    Graphics Card(s)
    Gigabyte RX 5700 XT Gaming OC
    Sound Card
    Realtek ALC1220P
    Monitor(s) Displays
    ASUS VE278 (x 2)
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro 256GB
    Samsung 970 Pro NVMe 512GB (x 2)
    ST10000VN0004 10TB (x 2)
    ST10000VN0008 10TB (x 2)
    ST4000VN000 4TB (x 2)
    PSU
    Corsair HX1000
    Case
    Corsair Carbide 400R
    Cooling
    AMD Wraith Prism (Stock)
    Keyboard
    Logitech G213
    Mouse
    Logitech G502
    Internet Speed
    100Mbps down / 40Mbps up
    Browser
    Firefox - Chrome - Edge
    Antivirus
    Windows Defender - Clamwin
BTW, for anyone looking at this thread and wondering what's he on about... I actually meant to post this to tenforums.com. Oops.

@Brink (or whomever) please feel free to relocate this to tenforums.com. In the meantime, I'll edit the title.
 

My Computer

System One

  • OS
    Windows 10/11
    Computer type
    Laptop
    Manufacturer/Model
    Acer
Back
Top Bottom