https://github.com/tomashubelbauer/powershell-wallpaper
Controlling the desktop wallpaper using PowerShell
https://github.com/tomashubelbauer/powershell-wallpaper
powershell
Last synced: 5 months ago
JSON representation
Controlling the desktop wallpaper using PowerShell
- Host: GitHub
- URL: https://github.com/tomashubelbauer/powershell-wallpaper
- Owner: TomasHubelbauer
- Created: 2019-12-02T19:07:48.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2022-04-14T21:08:44.000Z (almost 4 years ago)
- Last Synced: 2025-06-20T02:44:37.509Z (8 months ago)
- Topics: powershell
- Language: Markdown
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Powershell Wallpaper
Set the desktop wallpaper using PowerShell:
```powershell
# Using PowerShell to write to the registry
set-itemproperty -path "HKCU:Control Panel\Desktop" -name WallPaper -value "%UserProfile%\Desktop\wallpaper.jpg"
# Using `reg`
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v WallPaper /t REG_SZ /d "%UserProfile%\Desktop\wallpaper.jpg" /f
```
Clear the desktop wallpaper using PowerShell:
```powershell
# Using PowerShell to write to the registry
set-itemproperty -path "HKCU:Control Panel\Desktop" -name WallPaper -value ""
# Using `reg`
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v WallPaper /t REG_SZ /d "" /f
```
## Refreshing
The registry write will not have an immediate effect on the desktop background.
It is necessary to initiate a per user settings reload:
```powershell
RUNDLL32.EXE USER32.DLL, UpdatePerUserSystemParameters
```
## Resources
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa
## To-Do
### Hook into an event indicating `UpdatePerUserSystemParameters` completion
This will ensure the call went through successfully and will enable to hold the script until it does.
### Add working scripts for setting the desktop background color