Last active
July 31, 2016 05:11
-
-
Save svdamani/a1b72fe70e817f8d0360 to your computer and use it in GitHub Desktop.
Powershell script to set Bing wallpaper as desktop background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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