Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Set-Wallpaper {
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory=$True)]
- [ValidateScript({Test-Path $_})]
- [String]$WallpaperPath
- )
- Set-ItemProperty "REGISTRY::HKEY_CURRENT_USER\Control Panel\Desktop" -Name "Wallpaper" -Value "$WallpaperPath"
- taskkill /f /fi "status eq not responding" >$null
- $code = '[DllImport("user32.dll", CharSet = CharSet.Unicode)]'
- $code += "`npublic static extern uint UpdatePerUserSystemParameters();"
- $winApi = Add-Type -MemberDefinition $code -Name WinAPI -Namespace Extern -PassThru
- 0..12 | Foreach {$winApi::UpdatePerUserSystemParameters() >$null}
- $open_folders = @()
- $shell = New-Object -ComObject Shell.Application
- $shell.Windows() | Foreach {
- $open_folders += $_.LocationURL
- }
- Stop-Process -Name explorer -Force
- explorer.exe
- $open_folders | foreach {
- explorer $_
- }
- 0..12 | Foreach {$winApi::UpdatePerUserSystemParameters() >$null}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement