Last active
December 5, 2025 18:54
-
-
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.
This file contains hidden or 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
| # 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