Advertisement
spastek

Windows Recyclebin Themes Quick Automation

May 23rd, 2022
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##################################################################################################################
  2. # THIS IS A SCRIPT TO AUTOMATE THE PROCESS OF https://github.com/sdushantha/recycle-bin-themes                   #
  3. # PLEASE SEE https://www.reddit.com/r/pcmasterrace/comments/uw2se4/i_made_a_patrick_star_version_of_the_cat_bin/ #
  4. ##################################################################################################################
  5.  
  6. #Check for Administrator privileges and if not, open powershell as admin and rerun the script
  7. Write-Host "Checking for elevated privileges"
  8. If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
  9.     Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
  10.     Exit
  11. }
  12.  
  13. # Set the working location to the same location as the script
  14. Write-Host "Setting Working Directory to Script Root"
  15. Set-Location $PSScriptRoot
  16.  
  17. #Get .ico files from github the hard way
  18.  
  19. #patrik-star-empty.ico
  20. $pstarempty = "https://raw.githubusercontent.com/sdushantha/recycle-bin-themes/main/themes/patrick-star/patrik-star-empty.ico"
  21.  
  22. #patrik-star-full.ico
  23. $pstarfull = "https://raw.githubusercontent.com/sdushantha/recycle-bin-themes/main/themes/patrick-star/patrik-star-full.ico"
  24.  
  25. #pop-cat-empty.ico
  26. $pcatempty = "https://raw.githubusercontent.com/sdushantha/recycle-bin-themes/main/themes/pop-cat/pop-cat-empty.ico"
  27.  
  28. #pop-cat-full.ico
  29. $pcatfull = "https://raw.githubusercontent.com/sdushantha/recycle-bin-themes/main/themes/pop-cat/pop-cat-full.ico"
  30.  
  31. #Get user choice
  32. Write-Host "Please choose your theme:"
  33. $choice = Read-Host "Enter [1]POPCAT or [2]Patrik Star or [3]Default"
  34. if ($choice -eq '1' -or $choice -eq '2' -or $choice -eq '3') {
  35. Write-Host "You picked" $choice
  36. }else{
  37. Write-Host "You picked" $choice
  38. Write-Host "Please enter 1, 2, or 3."
  39. }
  40.  
  41. if ($choice -eq '1')
  42. {
  43. Write-Host "Downloading POPCAT Empty Icon"
  44. $url = $pcatempty
  45. $output = "$PSScriptRoot\pop-cat-empty.ico"
  46. Invoke-WebRequest -Uri $url -OutFile $output
  47. Write-Host "Downloading POPCAT Full Icon"
  48. $url = $pcatfull
  49. $output = "$PSScriptRoot\pop-cat-full.ico"
  50. Write-Host "Setting Registry"
  51. Invoke-WebRequest -Uri $url -OutFile $output
  52. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "(Default)" -Value "$PSScriptRoot\pop-cat-empty.ico,0"
  53. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "full" -Value "$PSScriptRoot\pop-cat-full.ico,0"
  54. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "empty" -Value "$PSScriptRoot\pop-cat-empty.ico,0"
  55. }
  56.  
  57. if ($choice -eq '2')
  58. {
  59. Write-Host "Downloading Patrik Star Empty Icon"
  60. $url = $pstarempty
  61. $output = "$PSScriptRoot\patrik-star-empty.ico"
  62. Invoke-WebRequest -Uri $url -OutFile $output
  63. Write-Host "Downloading Patrik Star Full Icon"
  64. $url = $pstarfull
  65. $output = "$PSScriptRoot\patrik-star-full.ico"
  66. Write-Host "Setting Registry"
  67. Invoke-WebRequest -Uri $url -OutFile $output
  68. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "(Default)" -Value "$PSScriptRoot\patrik-star-empty.ico,0"
  69. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "full" -Value "$PSScriptRoot\patrik-star-full.ico,0"
  70. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "empty" -Value "$PSScriptRoot\patrik-star-empty.ico,0"
  71. }
  72.  
  73. if ($choice -eq '3')
  74. {
  75. Write-Host "Resetting to default settings"
  76. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "(Default)" -Value "%SystemRoot%\System32\imageres.dll,-55"
  77. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "full" -Value "%SystemRoot%\System32\imageres.dll,-54"
  78. Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon" -Name "empty" -Value "%SystemRoot%\System32\imageres.dll,-55"
  79. }
  80.  
  81. #Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon
  82. #Default
  83. #(Default) = %SystemRoot%\System32\imageres.dll,-55
  84. #empty = %SystemRoot%\System32\imageres.dll,-55
  85. #full = %SystemRoot%\System32\imageres.dll,-54
  86.  
  87. #Refresh Desktop
  88.  $code = @'
  89.  [System.Runtime.InteropServices.DllImport("Shell32.dll")]
  90.  private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
  91.  
  92.  public static void Refresh()  {
  93.      SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);    
  94.  }
  95. '@
  96.  
  97. Add-Type -MemberDefinition $code -Namespace WinAPI -Name Explorer
  98. [WinAPI.Explorer]::Refresh()
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement