Last active
March 26, 2024 14:25
-
-
Save micahlt/4485e6a0007be5047a7e1d28029b5d72 to your computer and use it in GitHub Desktop.
Set elmo wallpaper
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
| Function Set-WallPaper($Image) { | |
| <# | |
| .SYNOPSIS | |
| Applies a specified wallpaper to the current user's desktop | |
| .PARAMETER Image | |
| Provide the exact path to the image | |
| .EXAMPLE | |
| Set-WallPaper -Image "C:\Wallpaper\Default.jpg" | |
| #> | |
| Add-Type -TypeDefinition @" | |
| using System; | |
| using System.Runtime.InteropServices; | |
| public class Params | |
| { | |
| [DllImport("User32.dll",CharSet=CharSet.Unicode)] | |
| public static extern int SystemParametersInfo (Int32 uAction, | |
| Int32 uParam, | |
| String lpvParam, | |
| Int32 fuWinIni); | |
| } | |
| "@ | |
| $SPI_SETDESKWALLPAPER = 0x0014 | |
| $UpdateIniFile = 0x01 | |
| $SendChangeEvent = 0x02 | |
| $fWinIni = $UpdateIniFile -bor $SendChangeEvent | |
| $ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni) | |
| } | |
| Invoke-WebRequest "https://cdn.micahlindley.com/assets/elmo.jpg" -OutFile "wp-el.jpg" | |
| $loc=Get-Location | |
| Set-WallPaper "$loc\wp-el.jpg" | Out-Null | |
| rm "wp-el.jpg" | |
| echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment