W10DebloaterGUI.ps1 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <# This form was created using POSHGUI.com a free online gui designer for PowerShell
  2. .NAME
  3. Untitled
  4. #>
  5. #This will self elevate the script so with a UAC prompt since this script needs to be run as an Administrator in order to function properly.
  6. <#$ErrorActionPreference = 'SilentlyContinue'
  7. $Button = [System.Windows.MessageBoxButton]::YesNoCancel
  8. $ErrorIco = [System.Windows.MessageBoxImage]::Error
  9. $Ask = 'Do you want to run this as an Administrator?
  10. Select "Yes" to Run as an Administrator
  11. Select "No" to not run this as an Administrator
  12. Select "Cancel" to stop the script.'
  13. If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
  14. $Prompt = [System.Windows.MessageBox]::Show($Ask, "Run as an Administrator or not?", $Button, $ErrorIco)
  15. Switch ($Prompt) {
  16. #This will debloat Windows 10
  17. Yes {
  18. Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
  19. Start-Process PowerShell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
  20. Exit
  21. }
  22. No {
  23. Break
  24. }
  25. }
  26. }#>
  27. $DebloatFolder = "C:\Temp\Windows10Debloater"
  28. If (Test-Path $DebloatFolder) {
  29. Write-Host "${DebloatFolder} exists."
  30. }
  31. Else {
  32. Write-Host "The folder ${DebloatFolder} doesn't exist. This folder will be used for storing logs created after the script runs. Creating now."
  33. Start-Sleep 1
  34. New-Item -Path "${DebloatFolder}" -ItemType Directory
  35. Write-Host "The folder ${DebloatFolder} was successfully created."
  36. }
  37. Start-Transcript -OutputDirectory "${DebloatFolder}"
  38. Add-Type -AssemblyName System.Windows.Forms
  39. Add-Type -AssemblyName PresentationCore, PresentationFramework
  40. [System.Windows.Forms.Application]::EnableVisualStyles()
  41. $Form = New-Object system.Windows.Forms.Form
  42. $Form.ClientSize = '875,616'
  43. $Form.text = "Windows 10 Debloater"
  44. $Form.TopMost = $false
  45. $ListBox1 = New-Object system.Windows.Forms.ListBox
  46. $ListBox1.text = "listBox"
  47. $ListBox1.width = 300
  48. $ListBox1.height = 494
  49. $ListBox1.location = New-Object System.Drawing.Point(3, 116)
  50. $ListBox1.SelectionMode = 'MultiExtended'
  51. $TextBox1 = New-Object system.Windows.Forms.RichTextBox
  52. $TextBox1.multiline = $True
  53. $TextBox1.width = 535
  54. $TextBox1.height = 400
  55. $TextBox1.location = New-Object System.Drawing.Point(325, 200)
  56. $TextBox1.Font = 'Microsoft Sans Serif,10'
  57. $Button1 = New-Object system.Windows.Forms.Button
  58. $Button1.text = "Uninstall"
  59. $Button1.width = 80
  60. $Button1.height = 30
  61. $Button1.location = New-Object System.Drawing.Point(5, 80)
  62. $Button1.Font = 'Microsoft Sans Serif,10'
  63. $Button2 = New-Object system.Windows.Forms.Button
  64. $Button2.text = "Apply Checkbox Changes"
  65. $Button2.width = 175
  66. $Button2.height = 30
  67. $Button2.location = New-Object System.Drawing.Point(685, 165)
  68. $Button2.Font = 'Microsoft Sans Serif,10'
  69. $Label1 = New-Object system.Windows.Forms.Label
  70. $Label1.text = "-----------------------------------------------------------------------------------------------------------------"
  71. $Label1.AutoSize = $true
  72. $Label1.width = 50
  73. $Label1.height = 10
  74. $Label1.location = New-Object System.Drawing.Point(305, 108)
  75. $Label1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 10)
  76. $CheckBox1 = New-Object system.Windows.Forms.CheckBox
  77. $CheckBox1.text = "Enable Cortana"
  78. $CheckBox1.AutoSize = $false
  79. $CheckBox1.width = 125
  80. $CheckBox1.height = 20
  81. $CheckBox1.location = New-Object System.Drawing.Point(325, 175)
  82. $CheckBox1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 10)
  83. $CheckBox2 = New-Object system.Windows.Forms.CheckBox
  84. $CheckBox2.text = "Disable Cortana"
  85. $CheckBox2.AutoSize = $false
  86. $CheckBox2.width = 125
  87. $CheckBox2.height = 20
  88. $CheckBox2.location = New-Object System.Drawing.Point(325, 150)
  89. $CheckBox2.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 10)
  90. $CheckBox3 = New-Object system.Windows.Forms.CheckBox
  91. $CheckBox3.text = "Uninstall OneDrive"
  92. $CheckBox3.AutoSize = $false
  93. $CheckBox3.width = 140
  94. $CheckBox3.height = 20
  95. $CheckBox3.location = New-Object System.Drawing.Point(475, 150)
  96. $CheckBox3.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 10)
  97. $CheckBox4 = New-Object system.Windows.Forms.CheckBox
  98. $CheckBox4.text = "Unpin Tiles From Start Menu"
  99. $CheckBox4.AutoSize = $false
  100. $CheckBox4.width = 200
  101. $CheckBox4.height = 20
  102. $CheckBox4.location = New-Object System.Drawing.Point(475, 175)
  103. $CheckBox4.Font = New-Object System.Drawing.Font('Microsoft Sans Serif', 10)
  104. $Form.controls.AddRange(@($ListBox1, $Button1, $Button2, $TextBox1, $CustomizeBlacklists, $CustomizeForm, $SaveList, $CustomizeBlacklists, $Checkbox1, $Checkbox2, $CheckBox3, $CheckBox4, $Label1))
  105. $global:Bloatware = @(
  106. "Microsoft.PPIProjection"
  107. "Microsoft.BingNews"
  108. "Microsoft.GetHelp"
  109. "Microsoft.Getstarted"
  110. "Microsoft.Messaging"
  111. "Microsoft.Microsoft3DViewer"
  112. "Microsoft.MicrosoftOfficeHub"
  113. "Microsoft.MicrosoftSolitaireCollection"
  114. "Microsoft.NetworkSpeedTest"
  115. "Microsoft.News" # Issue 77
  116. "Microsoft.Office.Lens" # Issue 77
  117. "Microsoft.Office.OneNote"
  118. "Microsoft.Office.Sway"
  119. "Microsoft.OneConnect"
  120. "Microsoft.People"
  121. "Microsoft.Print3D"
  122. "Microsoft.RemoteDesktop" # Issue 120
  123. "Microsoft.SkypeApp"
  124. "Microsoft.StorePurchaseApp"
  125. "Microsoft.Office.Todo.List" # Issue 77
  126. "Microsoft.Whiteboard" # Issue 77
  127. "Microsoft.WindowsAlarms"
  128. "microsoft.windowscommunicationsapps"
  129. "Microsoft.WindowsFeedbackHub"
  130. "Microsoft.WindowsMaps"
  131. "Microsoft.WindowsSoundRecorder"
  132. "Microsoft.Xbox.TCUI"
  133. "Microsoft.XboxApp"
  134. "Microsoft.XboxGameOverlay"
  135. "Microsoft.XboxGamingOverlay"
  136. "Microsoft.XboxIdentityProvider"
  137. "Microsoft.XboxSpeechToTextOverlay"
  138. "Microsoft.ZuneMusic"
  139. "Microsoft.ZuneVideo"
  140. #Sponsored Windows 10 AppX Apps
  141. #Add sponsored/featured apps to remove in the "*AppName*" format
  142. "EclipseManager"
  143. "ActiproSoftwareLLC"
  144. "AdobeSystemsIncorporated.AdobePhotoshopExpress"
  145. "Duolingo-LearnLanguagesforFree"
  146. "PandoraMediaInc"
  147. "CandyCrush"
  148. "BubbleWitch3Saga"
  149. "Wunderlist"
  150. "Flipboard"
  151. "Twitter"
  152. "Facebook"
  153. "Spotify" # Issue 123
  154. "Minecraft"
  155. "Royal Revolt"
  156. "Sway" # Issue 77
  157. "Dolby" # Issue 78
  158. #Optional: Typically not removed but you can if you need to for some reason
  159. #"Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe"
  160. #"Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe"
  161. #"Microsoft.BingWeather"
  162. )
  163. #$Windows10AppsFolder = Get-Item -path "C:\Program Files\WindowsApps\*"
  164. foreach ($Bloat in $Bloatware) {
  165. #$Apps = $App.Trim("C:\Program Files\WindowsApps\")
  166. $ListBox1.Items.Add($Bloat)
  167. $ListBox1.Sorted = $True
  168. }
  169. $Button = [Windows.MessageBoxButton]::YesNoCancel
  170. $ErrorIco = [Windows.MessageBoxImage]::Error
  171. $Warn = [Windows.MessageBoxImage]::Warning
  172. $Ask = 'Do you want to create a System Restore Point?
  173. Select "Yes" to create a System Restore Point
  174. Select "No" to not create a System Restore Point
  175. Select "Cancel" to stop the script.'
  176. $SelectedBloatware = $ListBox1.SelectedItems
  177. $Button1.Add_Click( {
  178. $Prompt1 = [Windows.MessageBox]::Show($Ask, "Create a System Restore Point?", $Button, $ErrorIco)
  179. Switch ($Prompt1) {
  180. Yes {
  181. $TextBox1.AppendText("Creating System Restore point. Please wait...
  182. ")
  183. Checkpoint-Computer -Description "Before using W10DebloaterGUI.ps1" -Verbose
  184. ForEach ($Selected in $SelectedBloatware) {
  185. $TextBox1.AppendText("Trying to remove $Selected...
  186. ")
  187. Try {
  188. If (Test-Path "C:\Program Files\WindowsApps\*$Selected*") {
  189. Get-AppxPackage | Where-Object { ($_.Name -match $Selected) } | Remove-AppxPackage
  190. Get-AppxProvisionedPackage -Online | Where-Object { ($_.Name -match $Selected) } | Remove-AppxProvisionedPackage -Online
  191. Get-AppxPackage -AllUsers | Where-Object { ($_.Name -match $Selected) } | Remove-AppxPackage
  192. $TextBox1.AppendText("Successfully removed $Selected!
  193. ")
  194. }
  195. Else {
  196. If (!(Test-Path "C:\Program Files\WindowsApps\*$Selected*")) {
  197. $TextBox1.AppendText("$Selected doesn't exist on this machine!
  198. ")
  199. }
  200. }
  201. }
  202. Catch {
  203. $TextBox1.AppendText("$_")
  204. }
  205. }
  206. }
  207. No {
  208. Break
  209. }
  210. }
  211. } )
  212. $Button2.Add_Click( {
  213. If ($CheckBox1.Checked) {
  214. $Textbox1.AppendText("Re-enabling Cortana to be used in your Windows Search")
  215. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  216. If (Test-Path $Search) {
  217. Set-ItemProperty $Search AllowCortana -Value 1
  218. }
  219. }
  220. If ($CheckBox2.Checked) {
  221. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  222. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  223. If (Test-Path $Search) {
  224. Set-ItemProperty $Search AllowCortana -Value 0
  225. }
  226. }
  227. If ($CheckBox3.Checked) {
  228. $RemoveOnedrive.Add_Click( {
  229. If (Test-Path "$env:USERPROFILE\OneDrive\*") {
  230. Write-Host "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
  231. Start-Sleep 1
  232. If (Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles") {
  233. Write-Host "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
  234. }
  235. else {
  236. If (!(Test-Path "$env:USERPROFILE\Desktop\OneDriveBackupFiles")) {
  237. Write-Host "A folder named OneDriveBackupFiles will be created and will be located on your desktop. All files from your OneDrive location will be located in that folder."
  238. New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
  239. Write-Host "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
  240. }
  241. }
  242. Start-Sleep 1
  243. Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
  244. Write-Host "Successfully moved all files/folders from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
  245. Start-Sleep 1
  246. Write-Host "Proceeding with the removal of OneDrive."
  247. Start-Sleep 1
  248. }
  249. Else {
  250. Write-Host "Either the OneDrive folder does not exist or there are no files to be found in the folder. Proceeding with removal of OneDrive."
  251. Start-Sleep 1
  252. Write-Host "Enabling the Group Policy 'Prevent the usage of OneDrive for File Storage'."
  253. $OneDriveKey = 'HKLM:Software\Policies\Microsoft\Windows\OneDrive'
  254. If (!(Test-Path $OneDriveKey)) {
  255. Mkdir $OneDriveKey
  256. Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
  257. }
  258. Set-ItemProperty $OneDriveKey -Name OneDrive -Value DisableFileSyncNGSC
  259. }
  260. Write-Host "Uninstalling OneDrive. Please wait..."
  261. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  262. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  263. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  264. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  265. Stop-Process -Name "OneDrive*"
  266. Start-Sleep 2
  267. If (!(Test-Path $onedrive)) {
  268. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  269. }
  270. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  271. Start-Sleep 2
  272. Write-Host "Stopping explorer"
  273. Start-Sleep 1
  274. taskkill.exe /F /IM explorer.exe
  275. Start-Sleep 3
  276. Write-Host "Removing leftover files"
  277. If (Test-Path "$env:USERPROFILE\OneDrive") {
  278. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  279. }
  280. If (Test-Path "$env:LOCALAPPDATA\Microsoft\OneDrive") {
  281. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  282. }
  283. If (Test-Path "$env:PROGRAMDATA\Microsoft OneDrive") {
  284. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  285. }
  286. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  287. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  288. }
  289. Write-Host "Removing OneDrive from windows explorer"
  290. If (!(Test-Path $ExplorerReg1)) {
  291. New-Item $ExplorerReg1
  292. }
  293. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  294. If (!(Test-Path $ExplorerReg2)) {
  295. New-Item $ExplorerReg2
  296. }
  297. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  298. Write-Host "Restarting Explorer that was shut down before."
  299. Start-Process explorer.exe -NoNewWindow
  300. Write-Host "OneDrive has been successfully uninstalled!"
  301. Remove-item env:OneDrive
  302. })
  303. }
  304. If ($CheckBox4.Checked) {
  305. #Credit to Vikingat-Rage
  306. #https://superuser.com/questions/1068382/how-to-remove-all-the-tiles-in-the-windows-10-start-menu
  307. #Unpins all tiles from the Start Menu
  308. Write-Host "Unpinning all tiles from the start menu"
  309. (New-Object -Com Shell.Application).
  310. NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
  311. Items() |
  312. % { $_.Verbs() } |
  313. ? { $_.Name -match 'Un.*pin from Start' } |
  314. % { $_.DoIt() }
  315. }
  316. } )
  317. [void]$Form.ShowDialog()