Skip to content

Instantly share code, notes, and snippets.

@daftspaniel
Created November 10, 2021 11:45
Show Gist options
  • Select an option

  • Save daftspaniel/90ba1bcc4612af596bfe0b2e3fd624c6 to your computer and use it in GitHub Desktop.

Select an option

Save daftspaniel/90ba1bcc4612af596bfe0b2e3fd624c6 to your computer and use it in GitHub Desktop.

Revisions

  1. daftspaniel created this gist Nov 10, 2021.
    23 changes: 23 additions & 0 deletions hexdslwallpaper.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # 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)