Created
June 10, 2025 21:07
-
-
Save ams0/316840dfa120d623de206d203ead535d to your computer and use it in GitHub Desktop.
set background in windows 11
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
# Define the path to the new wallpaper | |
$wallpaperPath = "C:\custom-background.jpg" | |
# Load user32.dll and define the SystemParametersInfo function | |
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class User32 { | |
[DllImport("user32.dll", CharSet = CharSet.Auto)] | |
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); | |
} | |
"@ | |
# Set the wallpaper | |
$SPI_SETDESKWALLPAPER = 0x0014 | |
$SPIF_UPDATEINIFILE = 0x01 | |
$SPIF_SENDCHANGE = 0x02 | |
$flags = $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE | |
[User32]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $wallpaperPath, $flags) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment