Skip to content

Instantly share code, notes, and snippets.

@svdamani
Last active July 31, 2016 05:11
Show Gist options
  • Save svdamani/a1b72fe70e817f8d0360 to your computer and use it in GitHub Desktop.
Save svdamani/a1b72fe70e817f8d0360 to your computer and use it in GitHub Desktop.
Powershell script to set Bing wallpaper as desktop background
[CmdletBinding()]
Param (
[ValidateRange(0, 18)] [int] $idx = 0,
[ValidateSet("en-US", "en-IN")] [string] $mkt = "en-IN"
)
$url = "http://www.bing.com/HPImageArchive.aspx?format=js&n=1&mkt=$mkt&idx=$idx"
$url = "http://www.bing.com" + (Invoke-RestMethod $url).images[0].url
$file = (Resolve-Path "~\Pictures\BingDesktop\").Path + $url.Split('/')[-1].Split('_')[0] + ".jpg"
if (-NOT (Test-Path $file)) { Invoke-WebRequest $url -OutFile $file }
Set-ItemProperty Wallpaper -Path "HKCU:\Control Panel\Desktop" -Value $file
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment