Last active
January 15, 2025 02:36
-
-
Save mark05e/12bf14eccd3b0a7b7b694c378577639c to your computer and use it in GitHub Desktop.
Maintenance Note - https://gist.github.com/mark05e/0a04a54c1e8489c770bd91e4910d7df9
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
#-------------------------------------------------------------------# | |
# ScriptName : SetWall.ps1 # | |
# Description : Force a Desktop wallpaper Refresh # | |
# Credits : Unknown (if you know original creator, let us know) # | |
# # | |
# Date : 01 July 2020 # | |
# Ref : https://c-nergy.be/blog/?p=15291 # | |
#-------------------------------------------------------------------# | |
#Modify Path to the picture accordingly to reflect your infrastructure | |
$imgPath="C:\Temp\Wallpaper.jpg" | |
if (!(Test-Path $imgPath -PathType leaf)) | |
{ | |
Write-Host "$imgPath not found!" | |
Exit | |
} | |
$code = @' | |
using System.Runtime.InteropServices; | |
namespace Win32{ | |
public class Wallpaper{ | |
[DllImport("user32.dll", CharSet=CharSet.Auto)] | |
static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ; | |
public static void SetWallpaper(string thePath){ | |
SystemParametersInfo(20,0,thePath,3); | |
} | |
} | |
} | |
'@ | |
add-type $code | |
#Apply the Change on the system | |
[Win32.Wallpaper]::SetWallpaper($imgPath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment