Skip to content

Instantly share code, notes, and snippets.

@endurtech
Last active December 5, 2025 18:54
Show Gist options
  • Select an option

  • Save endurtech/f85685cd6a4e76597f1eecfdbcf8f434 to your computer and use it in GitHub Desktop.

Select an option

Save endurtech/f85685cd6a4e76597f1eecfdbcf8f434 to your computer and use it in GitHub Desktop.
Tired of manually setting your desktop background? Discover how to use a simple PowerShell script to automatically change your Windows 11 wallpaper using this script.
# PowerShell Script to Change Desktop Wallpaper on Windows 11
# https://endurtech.com/powershell-script-to-change-desktop-wallpaper-on-windows-11/
$imgPath = "$env:USERPROFILE\Pictures\Photo1.png"
$code = @"
using System;
using System.Runtime.InteropServices;
public class Wallpaper
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
}
"@
Add-Type -TypeDefinition $code -Language CSharp
[Wallpaper]::SystemParametersInfo(20, 0, $imgPath, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment