Skip to content

Instantly share code, notes, and snippets.

@Workshop2
Created May 15, 2016 11:24
Show Gist options
  • Save Workshop2/4fa2fda523b628cb836b1c45111322f4 to your computer and use it in GitHub Desktop.
Save Workshop2/4fa2fda523b628cb836b1c45111322f4 to your computer and use it in GitHub Desktop.
Set wallpaper to today's Bing wallpaper (en-GB)
$wallpaperOutput = "$env:USERPROFILE\Pictures\wallpaper.jpg"
Write-Output "Downloading data feed..."
$wallpaperData = "http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-GB"
$json = (Invoke-WebRequest $wallpaperData -UseBasicParsing) | ConvertFrom-Json
$wallpaperUrl = "http://www.bing.com" + $json.images.urlbase + "_1920x1080.jpg"
Write-Output "Generated wallpaper URL: $wallpaperUrl"
Write-Output "Downloading wallpaper..."
Invoke-WebRequest $wallpaperUrl -OutFile $wallpaperOutput -UseBasicParsing
Write-Output "Setting registry key...HKCU:\Control Panel\Desktop\ -> wallpaper -> $wallpaperOutput"
Set-ItemProperty -path 'HKCU:\Control Panel\Desktop\' -name wallpaper -value $wallpaperOutput -force
rundll32.exe user32.dll, UpdatePerUserSystemParameters
rundll32.exe user32.dll, UpdatePerUserSystemParameters
rundll32.exe user32.dll, UpdatePerUserSystemParameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment