Forum Discussion
How to set desktop background from spotlight to picture option using powershell script
How to set desktop background from spotlight to picture option by setting registry key using powershell script
- Andres-BohrenSteel Contributor
Images from here? https://windows10spotlight.com/
#Invoke-WebRequest
$return = Invoke-WebRequest -Uri "https://windows10spotlight.com" -UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
#List Images
$return.images.src#Take first Image1URL
$Image1URL = $return.images.src[0]#Download File
Invoke-WebRequest -Uri $Image1URL -UserAgent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" -OutFile "C:\Temp\Background.jpg"#Set Background Image
$setwallpapersrc=@"
using System.Runtime.InteropServices;public class Wallpaper
{
public const int SetDesktopWallpaper = 20;
public const int UpdateIniFile = 0x01;
public const int SendWinIniChange = 0x02;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
public static void SetWallpaper(string path)
{
SystemParametersInfo(SetDesktopWallpaper, 0, path, UpdateIniFile | SendWinIniChange);
}
}
"@
Add-Type -TypeDefinition $setwallpapersrc
[Wallpaper]::SetWallpaper("C:\Temp\Background.jpg")Kind Regards
Andres
- Devika_SivakumarCopper Contributor
Thankyou for the reply , but I need powershell script to get option as picture under background for choosing instead of spotlight. Please find the attachment below
- Andres-BohrenSteel Contributor
Try to set it here
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers
Set-ItemProperty
Kind Regards
Andres