Guest User

refreshbg.ps1

a guest
Nov 7th, 2020
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Modify Path to the picture accordingly to reflect your infrastructure
  2. $imgPath="C:\windows\temp\b.bmp"
  3. $code = @'
  4. using System.Runtime.InteropServices;
  5. namespace Win32{
  6.  
  7. public class Wallpaper{
  8. [DllImport("user32.dll", CharSet=CharSet.Auto)]
  9. static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
  10.  
  11. public static void SetWallpaper(string thePath){
  12. SystemParametersInfo(20,0,thePath,3);
  13. }
  14. }
  15. }
  16. '@
  17.  
  18. add-type $code
  19.  
  20. #Apply the Change on the system
  21. [Win32.Wallpaper]::SetWallpaper($imgPath)
  22. for($i=1;$i -le 50;$i++){rundll32.exe user32.dll, UpdatePerUserSystemParameters, 1, true;Start-sleep -s 2}
  23. for($i=1;$i -le 50;$i++){rundll32.exe user32.dll, UpdatePerUserSystemParameters;Start-sleep -s 2}
RAW Paste Data