Skip to content

Instantly share code, notes, and snippets.

@daftspaniel
Created November 10, 2021 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daftspaniel/90ba1bcc4612af596bfe0b2e3fd624c6 to your computer and use it in GitHub Desktop.
Save daftspaniel/90ba1bcc4612af596bfe0b2e3fd624c6 to your computer and use it in GitHub Desktop.
Download and set the wallpaper from hexdsl.co.uk
# Change to image1 if you fancy a different wallpaper.
Invoke-WebRequest -Uri https://hexdsl.co.uk/image2.jpg -OutFile wall.jpg
# Pinched from Stackoverflow :-)
$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((Get-Item .\wall.jpg).fullname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment