Windows10DebloaterGUI.ps1 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. Add-Type -AssemblyName System.Windows.Forms
  2. [System.Windows.Forms.Application]::EnableVisualStyles()
  3. #region begin GUI{
  4. $Form = New-Object system.Windows.Forms.Form
  5. $Form.ClientSize = '408,523'
  6. $Form.text = "Windows10Debloater"
  7. $Form.TopMost = $false
  8. $Debloat = New-Object system.Windows.Forms.Label
  9. $Debloat.text = "Debloat Options"
  10. $Debloat.AutoSize = $true
  11. $Debloat.width = 25
  12. $Debloat.height = 10
  13. $Debloat.location = New-Object System.Drawing.Point(9, 8)
  14. $Debloat.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  15. $RemoveAllBloatware = New-Object system.Windows.Forms.Button
  16. $RemoveAllBloatware.text = "Remove All Bloatware"
  17. $RemoveAllBloatware.width = 142
  18. $RemoveAllBloatware.height = 40
  19. $RemoveAllBloatware.location = New-Object System.Drawing.Point(8, 32)
  20. $RemoveAllBloatware.Font = 'Microsoft Sans Serif,10'
  21. $RemoveBlacklist = New-Object system.Windows.Forms.Button
  22. $RemoveBlacklist.text = "Remove Bloatware With Blacklist"
  23. $RemoveBlacklist.width = 205
  24. $RemoveBlacklist.height = 37
  25. $RemoveBlacklist.location = New-Object System.Drawing.Point(9, 79)
  26. $RemoveBlacklist.Font = 'Microsoft Sans Serif,10'
  27. $Label1 = New-Object system.Windows.Forms.Label
  28. $Label1.text = "Revert Debloat "
  29. $Label1.AutoSize = $true
  30. $Label1.width = 25
  31. $Label1.height = 10
  32. $Label1.location = New-Object System.Drawing.Point(254, 7)
  33. $Label1.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  34. $RevertChange = New-Object system.Windows.Forms.Button
  35. $RevertChange.text = "Revert Changes"
  36. $RevertChange.width = 113
  37. $RevertChange.height = 36
  38. $RevertChange.location = New-Object System.Drawing.Point(254, 32)
  39. $RevertChange.Font = 'Microsoft Sans Serif,10'
  40. $Label2 = New-Object system.Windows.Forms.Label
  41. $Label2.text = "Optional Privacy Changes/Fixes"
  42. $Label2.AutoSize = $true
  43. $Label2.width = 25
  44. $Label2.height = 10
  45. $Label2.location = New-Object System.Drawing.Point(9, 193)
  46. $Label2.Font = 'Microsoft Sans Serif,12,style=Bold,Underline'
  47. $DisableCortana = New-Object system.Windows.Forms.Button
  48. $DisableCortana.text = "Disable Cortana"
  49. $DisableCortana.width = 111
  50. $DisableCortana.height = 36
  51. $DisableCortana.location = New-Object System.Drawing.Point(9, 217)
  52. $DisableCortana.Font = 'Microsoft Sans Serif,10'
  53. $EnableCortana = New-Object system.Windows.Forms.Button
  54. $EnableCortana.text = "Enable Cortana"
  55. $EnableCortana.width = 112
  56. $EnableCortana.height = 36
  57. $EnableCortana.location = New-Object System.Drawing.Point(9, 260)
  58. $EnableCortana.Font = 'Microsoft Sans Serif,10'
  59. $StopEdgePDFTakeover = New-Object system.Windows.Forms.Button
  60. $StopEdgePDFTakeover.text = "Stop Edge PDF Takeover"
  61. $StopEdgePDFTakeover.width = 161
  62. $StopEdgePDFTakeover.height = 38
  63. $StopEdgePDFTakeover.location = New-Object System.Drawing.Point(130, 217)
  64. $StopEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  65. $EnableEdgePDFTakeover = New-Object system.Windows.Forms.Button
  66. $EnableEdgePDFTakeover.text = "Enable Edge PDF Takeover"
  67. $EnableEdgePDFTakeover.width = 177
  68. $EnableEdgePDFTakeover.height = 39
  69. $EnableEdgePDFTakeover.location = New-Object System.Drawing.Point(130, 260)
  70. $EnableEdgePDFTakeover.Font = 'Microsoft Sans Serif,10'
  71. $DisableTelemetry = New-Object system.Windows.Forms.Button
  72. $DisableTelemetry.text = "Disable Telemetry/Tasks"
  73. $DisableTelemetry.width = 152
  74. $DisableTelemetry.height = 35
  75. $DisableTelemetry.location = New-Object System.Drawing.Point(9, 303)
  76. $DisableTelemetry.Font = 'Microsoft Sans Serif,10'
  77. $RemoveRegkeys = New-Object system.Windows.Forms.Button
  78. $RemoveRegkeys.text = "Remove Bloatware Regkeys"
  79. $RemoveRegkeys.width = 177
  80. $RemoveRegkeys.height = 40
  81. $RemoveRegkeys.location = New-Object System.Drawing.Point(169, 303)
  82. $RemoveRegkeys.Font = 'Microsoft Sans Serif,10'
  83. $RemoveOnedrive = New-Object system.Windows.Forms.Button
  84. $RemoveOnedrive.text = "Uninstall OneDrive"
  85. $RemoveOnedrive.width = 117
  86. $RemoveOnedrive.height = 35
  87. $RemoveOnedrive.location = New-Object System.Drawing.Point(9, 345)
  88. $RemoveOnedrive.Font = 'Microsoft Sans Serif,10'
  89. $FixWhitelist = New-Object system.Windows.Forms.Button
  90. $FixWhitelist.text = "Fix Whitelisted Apps"
  91. $FixWhitelist.width = 130
  92. $FixWhitelist.height = 37
  93. $FixWhitelist.location = New-Object System.Drawing.Point(254, 74)
  94. $FixWhitelist.Font = 'Microsoft Sans Serif,10'
  95. $RemoveBloatNoBlacklist = New-Object system.Windows.Forms.Button
  96. $RemoveBloatNoBlacklist.text = "Remove Bloatware Without Blacklist"
  97. $RemoveBloatNoBlacklist.width = 223
  98. $RemoveBloatNoBlacklist.height = 39
  99. $RemoveBloatNoBlacklist.location = New-Object System.Drawing.Point(9, 123)
  100. $RemoveBloatNoBlacklist.Font = 'Microsoft Sans Serif,10'
  101. $Form.controls.AddRange(@($Debloat, $RemoveAllBloatware, $RemoveBlacklist, $Label1, $RevertChange, $Label2, $DisableCortana, $EnableCortana, $StopEdgePDFTakeover, $EnableEdgePDFTakeover, $DisableTelemetry, $RemoveRegkeys, $RemoveOnedrive, $FixWhitelist, $RemoveBloatNoBlacklist))
  102. #region gui events {
  103. $RemoveBlacklist.Add_Click( {
  104. $ErrorActionPreference = 'silentlycontinue'
  105. Function DebloatBlacklist {
  106. [CmdletBinding()]
  107. Param ()
  108. $Bloatware = @(
  109. #Unnecessary Windows 10 AppX Apps
  110. "Microsoft.BingNews"
  111. "Microsoft.DesktopAppInstaller"
  112. "Microsoft.GetHelp"
  113. "Microsoft.Getstarted"
  114. "Microsoft.Messaging"
  115. "Microsoft.Microsoft3DViewer"
  116. "Microsoft.MicrosoftOfficeHub"
  117. "Microsoft.MicrosoftSolitaireCollection"
  118. "Microsoft.NetworkSpeedTest"
  119. "Microsoft.Office.OneNote"
  120. "Microsoft.Office.Sway"
  121. "Microsoft.OneConnect"
  122. "Microsoft.People"
  123. "Microsoft.Print3D"
  124. "Microsoft.RemoteDesktop"
  125. "Microsoft.SkypeApp"
  126. "Microsoft.StorePurchaseApp"
  127. "Microsoft.WindowsAlarms"
  128. "Microsoft.WindowsCamera"
  129. "microsoft.windowscommunicationsapps"
  130. "Microsoft.WindowsFeedbackHub"
  131. "Microsoft.WindowsMaps"
  132. "Microsoft.WindowsSoundRecorder"
  133. "Microsoft.Xbox.TCUI"
  134. "Microsoft.XboxApp"
  135. "Microsoft.XboxGameOverlay"
  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. "*Wunderlist*"
  149. "*Flipboard*"
  150. "*Twitter*"
  151. "*Facebook*"
  152. "*Spotify*"
  153. "*Minecraft*"
  154. "*Royal Revolt*"
  155. #Optional: Typically not removed but you can if you need to for some reason
  156. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  157. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  158. #"*Microsoft.BingWeather*"
  159. #"*Microsoft.MSPaint*"
  160. #"*Microsoft.MicrosoftStickyNotes*"
  161. #"*Microsoft.Windows.Photos*"
  162. #"*Microsoft.WindowsCalculator*"
  163. #"*Microsoft.WindowsStore*"
  164. )
  165. foreach ($Bloat in $Bloatware) {
  166. Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
  167. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  168. Write-Host "Trying to remove $Bloat."
  169. Write-Host "Bloatware removed! `n"
  170. }
  171. }
  172. Write-Host "Removing Bloatware with a specific blacklist."
  173. DebloatBlacklist
  174. })
  175. $RemoveAllBloatware.Add_Click( {
  176. $ErrorActionPreference = 'silentlycontinue'
  177. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  178. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  179. #This is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
  180. Function Begin-SysPrep {
  181. $ErrorActionPreference = 'silentlycontinue'
  182. Write-Host -Message ('Starting Sysprep Fixes')
  183. # Disable Windows Store Automatic Updates
  184. Write-Host -Message "Adding Registry key to Disable Windows Store Automatic Updates"
  185. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  186. If (!(Test-Path $registryPath)) {
  187. Mkdir $registryPath -ErrorAction SilentlyContinue
  188. New-ItemProperty $registryPath -Name AutoDownload -Value 2
  189. }
  190. Else {
  191. Set-ItemProperty $registryPath -Name AutoDownload -Value 2
  192. }
  193. #Stop WindowsStore Installer Service and set to Disabled
  194. Write-Host -Message ('Stopping InstallService')
  195. Stop-Service InstallService
  196. Write-Host -Message ('Setting InstallService Startup to Disabled')
  197. & Set-Service -Name InstallService -StartupType Disabled
  198. }
  199. Function DebloatAll {
  200. [CmdletBinding()]
  201. Param()
  202. #Removes AppxPackages
  203. #Credit to /u/GavinEke for a modified version of my whitelist code
  204. [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows|Microsoft.XboxGameCallableUI|Microsoft.XboxGamingOverlay|Microsoft.Xbox.TCUI|Microsoft.XboxGamingOverlay|Microsoft.XboxIdentityProvider|Microsoft.MicrosoftStickyNotes|Microsoft.MSPaint'
  205. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  206. Get-AppxPackage | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage
  207. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online
  208. }
  209. #Creates a PSDrive to be able to access the 'HKCR' tree
  210. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  211. Function DebloatBlacklist {
  212. $ErrorActionPreference = 'silentlycontinue'
  213. $Bloatware = @(
  214. #Unnecessary Windows 10 AppX Apps
  215. "Microsoft.BingNews"
  216. "Microsoft.DesktopAppInstaller"
  217. "Microsoft.GetHelp"
  218. "Microsoft.Getstarted"
  219. "Microsoft.Messaging"
  220. "Microsoft.Microsoft3DViewer"
  221. "Microsoft.MicrosoftOfficeHub"
  222. "Microsoft.MicrosoftSolitaireCollection"
  223. "Microsoft.NetworkSpeedTest"
  224. "Microsoft.Office.OneNote"
  225. "Microsoft.Office.Sway"
  226. "Microsoft.OneConnect"
  227. "Microsoft.People"
  228. "Microsoft.Print3D"
  229. "Microsoft.RemoteDesktop"
  230. "Microsoft.SkypeApp"
  231. "Microsoft.StorePurchaseApp"
  232. "Microsoft.WindowsAlarms"
  233. "Microsoft.WindowsCamera"
  234. "microsoft.windowscommunicationsapps"
  235. "Microsoft.WindowsFeedbackHub"
  236. "Microsoft.WindowsMaps"
  237. "Microsoft.WindowsSoundRecorder"
  238. "Microsoft.Xbox.TCUI"
  239. "Microsoft.XboxApp"
  240. "Microsoft.XboxGameOverlay"
  241. "Microsoft.XboxIdentityProvider"
  242. "Microsoft.XboxSpeechToTextOverlay"
  243. "Microsoft.ZuneMusic"
  244. "Microsoft.ZuneVideo"
  245. #Sponsored Windows 10 AppX Apps
  246. #Add sponsored/featured apps to remove in the "*AppName*" format
  247. "*EclipseManager*"
  248. "*ActiproSoftwareLLC*"
  249. "*AdobeSystemsIncorporated.AdobePhotoshopExpress*"
  250. "*Duolingo-LearnLanguagesforFree*"
  251. "*PandoraMediaInc*"
  252. "*CandyCrush*"
  253. "*Wunderlist*"
  254. "*Flipboard*"
  255. "*Twitter*"
  256. "*Facebook*"
  257. "*Spotify*"
  258. "*Minecraft*"
  259. "*Royal Revolt*"
  260. #Optional: Typically not removed but you can if you need to for some reason
  261. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*"
  262. #"*Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*"
  263. #"*Microsoft.BingWeather*"
  264. #"*Microsoft.MSPaint*"
  265. #"*Microsoft.MicrosoftStickyNotes*"
  266. #"*Microsoft.Windows.Photos*"
  267. #"*Microsoft.WindowsCalculator*"
  268. #"*Microsoft.WindowsStore*"
  269. )
  270. foreach ($Bloat in $Bloatware) {
  271. Get-AppxPackage -Name $Bloat| Remove-AppxPackage -ErrorAction SilentlyContinue
  272. Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $Bloat | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  273. Write-Host "Trying to remove $Bloat."
  274. }
  275. }
  276. Function Remove-Keys {
  277. $ErrorActionPreference = 'silentlycontinue'
  278. #These are the registry keys that it will delete.
  279. $Keys = @(
  280. #Remove Background Tasks
  281. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  282. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  283. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  284. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  285. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  286. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  287. #Windows File
  288. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  289. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  290. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  291. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  292. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  293. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  294. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  295. #Scheduled Tasks to delete
  296. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  297. #Windows Protocol Keys
  298. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  299. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  300. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  301. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  302. #Windows Share Target
  303. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  304. )
  305. #This writes the output of each key it is removing and also removes the keys listed above.
  306. ForEach ($Key in $Keys) {
  307. Write-Host "Removing $Key from registry"
  308. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  309. }
  310. }
  311. Function Protect-Privacy {
  312. $ErrorActionPreference = 'silentlycontinue'
  313. #Creates a PSDrive to be able to access the 'HKCR' tree
  314. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  315. #Disables Windows Feedback Experience
  316. Write-Host "Disabling Windows Feedback Experience program"
  317. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  318. If (Test-Path $Advertising) {
  319. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  320. }
  321. #Stops Cortana from being used as part of your Windows Search Function
  322. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  323. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  324. If (Test-Path $Search) {
  325. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  326. }
  327. #Stops the Windows Feedback Experience from sending anonymous data
  328. Write-Host "Stopping the Windows Feedback Experience program"
  329. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  330. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  331. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  332. If (!(Test-Path $Period3)) {
  333. mkdir $Period1 -ErrorAction SilentlyContinue
  334. mkdir $Period2 -ErrorAction SilentlyContinue
  335. mkdir $Period3 -ErrorAction SilentlyContinue
  336. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  337. }
  338. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  339. #Prevents bloatware applications from returning
  340. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  341. If (!(Test-Path $registryPath)) {
  342. Mkdir $registryPath -ErrorAction SilentlyContinue
  343. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  344. }
  345. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  346. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  347. If (Test-Path $Holo) {
  348. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  349. }
  350. #Disables live tiles
  351. Write-Host "Disabling live tiles"
  352. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  353. If (!(Test-Path $Live)) {
  354. mkdir $Live -ErrorAction SilentlyContinue
  355. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  356. }
  357. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  358. Write-Host "Turning off Data Collection"
  359. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  360. If (Test-Path $DataCollection) {
  361. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  362. }
  363. #Disables People icon on Taskbar
  364. Write-Host "Disabling People icon on Taskbar"
  365. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  366. If (!(Test-Path $People)) {
  367. mkdir $People -ErrorAction SilentlyContinue
  368. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  369. }
  370. #Disables suggestions on start menu
  371. Write-Host "Disabling suggestions on the Start Menu"
  372. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  373. If (Test-Path $Suggestions) {
  374. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  375. }
  376. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  377. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  378. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  379. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  380. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  381. reg unload HKU\Default_User
  382. #Disables scheduled tasks that are considered unnecessary
  383. Write-Host "Disabling scheduled tasks"
  384. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask -ErrorAction SilentlyContinue
  385. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue
  386. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue
  387. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue
  388. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue
  389. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue
  390. }
  391. #This includes fixes by xsisbest
  392. Function FixWhitelistedApps {
  393. $ErrorActionPreference = 'silentlycontinue'
  394. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.MSPaint, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.MicrosoftStickyNotes, Microsoft.WindowsSoundRecorder, Microsoft.Windows.Photos)) {
  395. #Credit to abulgatz for the 4 lines of code
  396. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  397. Get-AppxPackage -allusers Microsoft.MSPaint | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  398. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  399. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  400. Get-AppxPackage -allusers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  401. Get-AppxPackage -allusers Microsoft.WindowsSoundRecorder | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  402. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  403. }
  404. }
  405. Function CheckDMWService {
  406. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  407. Start-Service -Name dmwappushservice
  408. }
  409. }
  410. Function CheckInstallService {
  411. If (Get-Service -Name InstallService | Where-Object {$_.Status -eq "Stopped"}) {
  412. Start-Service -Name InstallService
  413. Set-Service -Name InstallService -StartupType Automatic
  414. }
  415. }
  416. Write-Host "Initiating Sysprep"
  417. Begin-SysPrep
  418. Write-Host "Removing bloatware apps."
  419. DebloatAll
  420. DebloatBlacklist
  421. Write-Host "Removing leftover bloatware registry keys."
  422. Remove-Keys
  423. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  424. FixWhitelistedApps
  425. Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  426. Protect-Privacy
  427. #Write-Host "Stopping Edge from taking over as the default PDF Viewer."
  428. #Stop-EdgePDF
  429. Write-Output "Setting the 'InstallService' Windows service back to "Started" and the Startup Type "Automatic".
  430. CheckDMWService
  431. CheckInstallService
  432. Write-Host "Finished all tasks. `n"
  433. } )
  434. $RemoveBloatNoBlacklist.Add_Click( {
  435. $ErrorActionPreference = 'silentlycontinue'
  436. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  437. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  438. #This is the switch parameter for running this script as a 'silent' script, for use in MDT images or any type of mass deployment without user interaction.
  439. param (
  440. [switch]$Debloat, [switch]$SysPrep
  441. )
  442. Function Begin-SysPrep {
  443. $ErrorActionPreference = 'silentlycontinue'
  444. param([switch]$SysPrep)
  445. Write-Host -Message ('Starting Sysprep Fixes')
  446. # Disable Windows Store Automatic Updates
  447. Write-Host -Message "Adding Registry key to Disable Windows Store Automatic Updates"
  448. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  449. If (!(Test-Path $registryPath)) {
  450. Mkdir $registryPath -ErrorAction SilentlyContinue
  451. New-ItemProperty $registryPath -Name AutoDownload -Value 2
  452. }
  453. Else {
  454. Set-ItemProperty $registryPath -Name AutoDownload -Value 2
  455. }
  456. #Stop WindowsStore Installer Service and set to Disabled
  457. Write-Host -Message ('Stopping InstallService')
  458. Stop-Service InstallService
  459. Write-Host -Message ('Setting InstallService Startup to Disabled')
  460. & Set-Service -Name InstallService -StartupType Disabled
  461. }
  462. #Creates a PSDrive to be able to access the 'HKCR' tree
  463. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  464. Function Start-Debloat {
  465. $ErrorActionPreference = 'silentlycontinue'
  466. param([switch]$Debloat)
  467. #Removes AppxPackages
  468. #Credit to Reddit user /u/GavinEke for a modified version of my whitelist code
  469. [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.MSPaint|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.MicrosoftStickyNotes|Microsoft.WindowsSoundRecorder|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows'
  470. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue
  471. # Run this again to avoid error on 1803 or having to reboot.
  472. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue
  473. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  474. }
  475. Function Remove-Keys {
  476. $ErrorActionPreference = 'silentlycontinue'
  477. Param([switch]$Debloat)
  478. #These are the registry keys that it will delete.
  479. $Keys = @(
  480. #Remove Background Tasks
  481. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  482. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  483. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  484. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  485. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  486. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  487. #Windows File
  488. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  489. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  490. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  491. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  492. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  493. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  494. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  495. #Scheduled Tasks to delete
  496. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  497. #Windows Protocol Keys
  498. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  499. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  500. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  501. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  502. #Windows Share Target
  503. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  504. )
  505. #This writes the output of each key it is removing and also removes the keys listed above.
  506. ForEach ($Key in $Keys) {
  507. Write-Host "Removing $Key from registry"
  508. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  509. }
  510. }
  511. Function Protect-Privacy {
  512. $ErrorActionPreference = 'silentlycontinue'
  513. Param([switch]$Debloat)
  514. #Creates a PSDrive to be able to access the 'HKCR' tree
  515. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  516. #Disables Windows Feedback Experience
  517. Write-Host "Disabling Windows Feedback Experience program"
  518. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  519. If (Test-Path $Advertising) {
  520. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  521. }
  522. #Stops Cortana from being used as part of your Windows Search Function
  523. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  524. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  525. If (Test-Path $Search) {
  526. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  527. }
  528. #Stops the Windows Feedback Experience from sending anonymous data
  529. Write-Host "Stopping the Windows Feedback Experience program"
  530. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  531. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  532. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  533. If (!(Test-Path $Period3)) {
  534. mkdir $Period1 -ErrorAction SilentlyContinue
  535. mkdir $Period2 -ErrorAction SilentlyContinue
  536. mkdir $Period3 -ErrorAction SilentlyContinue
  537. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  538. }
  539. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  540. #Prevents bloatware applications from returning
  541. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  542. If (!(Test-Path $registryPath)) {
  543. Mkdir $registryPath -ErrorAction SilentlyContinue
  544. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  545. }
  546. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  547. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  548. If (Test-Path $Holo) {
  549. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  550. }
  551. #Disables live tiles
  552. Write-Host "Disabling live tiles"
  553. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  554. If (!(Test-Path $Live)) {
  555. mkdir $Live -ErrorAction SilentlyContinue
  556. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  557. }
  558. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  559. Write-Host "Turning off Data Collection"
  560. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  561. If (Test-Path $DataCollection) {
  562. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  563. }
  564. #Disables People icon on Taskbar
  565. Write-Host "Disabling People icon on Taskbar"
  566. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  567. If (!(Test-Path $People)) {
  568. mkdir $People -ErrorAction SilentlyContinue
  569. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  570. }
  571. #Disables suggestions on start menu
  572. Write-Host "Disabling suggestions on the Start Menu"
  573. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  574. If (Test-Path $Suggestions) {
  575. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  576. }
  577. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  578. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  579. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  580. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  581. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  582. reg unload HKU\Default_User
  583. #Disables scheduled tasks that are considered unnecessary
  584. Write-Host "Disabling scheduled tasks"
  585. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask -ErrorAction SilentlyContinue
  586. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue
  587. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue
  588. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue
  589. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue
  590. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue
  591. }
  592. #This includes fixes by xsisbest
  593. Function FixWhitelistedApps {
  594. Param([switch]$Debloat)
  595. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.MSPaint, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.MicrosoftStickyNotes, Microsoft.WindowsSoundRecorder, Microsoft.Windows.Photos)) {
  596. #Credit to abulgatz for the 4 lines of code
  597. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  598. Get-AppxPackage -allusers Microsoft.MSPaint | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  599. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  600. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  601. Get-AppxPackage -allusers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  602. Get-AppxPackage -allusers Microsoft.WindowsSoundRecorder | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  603. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  604. }
  605. }
  606. Function CheckDMWService {
  607. Param([switch]$Debloat)
  608. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  609. Start-Service -Name dmwappushservice
  610. }
  611. }
  612. Function CheckInstallService {
  613. If (Get-Service -Name InstallService | Where-Object {$_.Status -eq "Stopped"}) {
  614. Start-Service -Name InstallService
  615. Set-Service -Name InstallService -StartupType Automatic
  616. }
  617. }
  618. Begin-SysPrep
  619. Write-Host "Removing bloatware apps."
  620. Start-Debloat
  621. Write-Host "Removing leftover bloatware registry keys."
  622. Remove-Keys
  623. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  624. FixWhitelistedApps
  625. Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  626. Protect-Privacy
  627. #Write-Host "Stopping Edge from taking over as the default PDF Viewer."
  628. Write-Host "Checking to make sure that the service 'dmwappushservice' has been started."
  629. CheckDMWService
  630. Write-Output "Setting the 'InstallService' Windows service back to started and setting the Startup Type to "Automatic".
  631. CheckInstallService
  632. Write-Host "Finished all tasks. `n"
  633. })
  634. $RevertChange.Add_Click( {
  635. $ErrorActionPreference = 'silentlycontinue'
  636. #This function will revert the changes you made when running the Start-Debloat function.
  637. #This line reinstalls all of the bloatware that was removed
  638. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  639. #Tells Windows to enable your advertising information.
  640. Write-Host "Re-enabling key to show advertisement information"
  641. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  642. If (Test-Path $Advertising) {
  643. Set-ItemProperty $Advertising Enabled -Value 1
  644. }
  645. #Enables Cortana to be used as part of your Windows Search Function
  646. Write-Host "Re-enabling Cortana to be used in your Windows Search"
  647. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  648. If (Test-Path $Search) {
  649. Set-ItemProperty $Search AllowCortana -Value 1
  650. }
  651. #Re-enables the Windows Feedback Experience for sending anonymous data
  652. Write-Host "Re-enabling Windows Feedback Experience"
  653. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  654. If (!(Test-Path $Period)) {
  655. New-Item $Period
  656. }
  657. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  658. #Enables bloatware applications
  659. Write-Host "Adding Registry key to allow bloatware apps to return"
  660. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  661. If (!(Test-Path $registryPath)) {
  662. New-Item $registryPath
  663. }
  664. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  665. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  666. Write-Host "Setting Mixed Reality Portal value to 1"
  667. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  668. If (Test-Path $Holo) {
  669. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  670. }
  671. #Re-enables live tiles
  672. Write-Host "Enabling live tiles"
  673. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  674. If (!(Test-Path $Live)) {
  675. New-Item $Live
  676. }
  677. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  678. #Re-enables data collection
  679. Write-Host "Re-enabling data collection"
  680. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  681. If (!(Test-Path $DataCollection)) {
  682. New-Item $DataCollection
  683. }
  684. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  685. #Re-enables People Icon on Taskbar
  686. Write-Host "Enabling People icon on Taskbar"
  687. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  688. If (!(Test-Path $People)) {
  689. New-Item $People
  690. }
  691. Set-ItemProperty $People PeopleBand -Value 1
  692. #Re-enables suggestions on start menu
  693. Write-Host "Enabling suggestions on the Start Menu"
  694. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  695. If (!(Test-Path $Suggestions)) {
  696. New-Item $Suggestions
  697. }
  698. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  699. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  700. Write-Host "Enabling scheduled tasks that were disabled"
  701. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  702. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  703. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  704. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  705. Get-ScheduledTask DmClient | Enable-ScheduledTask
  706. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  707. Write-Host "Re-enabling and starting WAP Push Service"
  708. #Enable and start WAP Push Service
  709. Set-Service "dmwappushservice" -StartupType Automatic
  710. Start-Service "dmwappushservice"
  711. Write-Host "Re-enabling and starting the Diagnostics Tracking Service"
  712. #Enabling the Diagnostics Tracking Service
  713. Set-Service "DiagTrack" -StartupType Automatic
  714. Start-Service "DiagTrack"
  715. Write-Host "Done reverting changes! `n"
  716. })
  717. $FixWhitelist.Add_Click( {
  718. $ErrorActionPreference = 'silentlycontinue'
  719. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  720. #Credit to abulgatz for these 4 lines of code
  721. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  722. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  723. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  724. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  725. }
  726. Write-Host "Whitelisted apps were either fixed or re-added. `n"
  727. })
  728. $DisableCortana.Add_Click( {
  729. $ErrorActionPreference = 'silentlycontinue'
  730. Write-Host "Disabling Cortana"
  731. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  732. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  733. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  734. If (!(Test-Path $Cortana1)) {
  735. New-Item $Cortana1
  736. }
  737. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  738. If (!(Test-Path $Cortana2)) {
  739. New-Item $Cortana2
  740. }
  741. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  742. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  743. If (!(Test-Path $Cortana3)) {
  744. New-Item $Cortana3
  745. }
  746. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  747. Write-Host "Cortana has been disabled. `n"
  748. })
  749. $StopEdgePDFTakeover.Add_Click( {
  750. $ErrorActionPreference = 'silentlycontinue'
  751. #Stops edge from taking over as the default .PDF viewer
  752. Write-Host "Stopping Edge from taking over as the default .PDF viewer"
  753. $NoPDF = "HKCR:\.pdf"
  754. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  755. $NoWithList = "HKCR:\.pdf\OpenWithList"
  756. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  757. New-ItemProperty $NoPDF NoOpenWith
  758. }
  759. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  760. New-ItemProperty $NoPDF NoStaticDefaultVerb
  761. }
  762. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  763. New-ItemProperty $NoProgids NoOpenWith
  764. }
  765. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  766. New-ItemProperty $NoProgids NoStaticDefaultVerb
  767. }
  768. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  769. New-ItemProperty $NoWithList NoOpenWith
  770. }
  771. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  772. New-ItemProperty $NoWithList NoStaticDefaultVerb
  773. }
  774. #Appends an underscore '_' to the Registry key for Edge
  775. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  776. If (Test-Path $Edge) {
  777. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  778. }
  779. Write-Host "Edge should no longer take over as the default .PDF. `n"
  780. })
  781. $EnableCortana.Add_Click( {
  782. $ErrorActionPreference = 'silentlycontinue'
  783. Write-Host "Re-enabling Cortana"
  784. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  785. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  786. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  787. If (!(Test-Path $Cortana1)) {
  788. New-Item $Cortana1
  789. }
  790. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  791. If (!(Test-Path $Cortana2)) {
  792. New-Item $Cortana2
  793. }
  794. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  795. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  796. If (!(Test-Path $Cortana3)) {
  797. New-Item $Cortana3
  798. }
  799. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  800. Write-Host "Cortana has been enabled! `n"
  801. })
  802. $EnableEdgePDFTakeover.Add_Click( {
  803. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  804. $ErrorActionPreference = 'silentlycontinue'
  805. Write-Host "Setting Edge back to default"
  806. $NoPDF = "HKCR:\.pdf"
  807. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  808. $NoWithList = "HKCR:\.pdf\OpenWithList"
  809. #Sets edge back to default
  810. If (Get-ItemProperty $NoPDF NoOpenWith) {
  811. Remove-ItemProperty $NoPDF NoOpenWith
  812. }
  813. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  814. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  815. }
  816. If (Get-ItemProperty $NoProgids NoOpenWith) {
  817. Remove-ItemProperty $NoProgids NoOpenWith
  818. }
  819. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  820. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  821. }
  822. If (Get-ItemProperty $NoWithList NoOpenWith) {
  823. Remove-ItemProperty $NoWithList NoOpenWith
  824. }
  825. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  826. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  827. }
  828. #Removes an underscore '_' from the Registry key for Edge
  829. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  830. If (Test-Path $Edge2) {
  831. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  832. }
  833. Write-Host "Edge will now be able to be used for .PDF. `n"
  834. })
  835. $DisableTelemetry.Add_Click( {
  836. $ErrorActionPreference = 'silentlycontinue'
  837. #Disables Windows Feedback Experience
  838. Write-Host "Disabling Windows Feedback Experience program"
  839. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  840. If (Test-Path $Advertising) {
  841. Set-ItemProperty $Advertising Enabled -Value 0
  842. }
  843. #Stops Cortana from being used as part of your Windows Search Function
  844. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  845. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  846. If (Test-Path $Search) {
  847. Set-ItemProperty $Search AllowCortana -Value 0
  848. }
  849. #Disables Web Search in Start Menu
  850. Write-Host "Disabling Bing Search in Start Menu"
  851. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  852. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  853. If (!(Test-Path $WebSearch)) {
  854. New-Item $WebSearch
  855. }
  856. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  857. #Stops the Windows Feedback Experience from sending anonymous data
  858. Write-Host "Stopping the Windows Feedback Experience program"
  859. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  860. If (!(Test-Path $Period)) {
  861. New-Item $Period
  862. }
  863. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  864. #Prevents bloatware applications from returning and removes Start Menu suggestions
  865. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  866. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  867. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  868. If (!(Test-Path $registryPath)) {
  869. New-Item $registryPath
  870. }
  871. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  872. If (!(Test-Path $registryOEM)) {
  873. New-Item $registryOEM
  874. }
  875. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  876. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  877. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  878. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  879. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  880. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  881. #Preping mixed Reality Portal for removal
  882. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  883. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  884. If (Test-Path $Holo) {
  885. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  886. }
  887. #Disables Wi-fi Sense
  888. Write-Host "Disabling Wi-Fi Sense"
  889. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  890. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  891. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  892. If (!(Test-Path $WifiSense1)) {
  893. New-Item $WifiSense1
  894. }
  895. Set-ItemProperty $WifiSense1 Value -Value 0
  896. If (!(Test-Path $WifiSense2)) {
  897. New-Item $WifiSense2
  898. }
  899. Set-ItemProperty $WifiSense2 Value -Value 0
  900. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  901. #Disables live tiles
  902. Write-Host "Disabling live tiles"
  903. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  904. If (!(Test-Path $Live)) {
  905. New-Item $Live
  906. }
  907. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  908. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  909. Write-Host "Turning off Data Collection"
  910. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  911. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  912. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  913. If (Test-Path $DataCollection1) {
  914. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  915. }
  916. If (Test-Path $DataCollection2) {
  917. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  918. }
  919. If (Test-Path $DataCollection3) {
  920. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  921. }
  922. #Disabling Location Tracking
  923. Write-Host "Disabling Location Tracking"
  924. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  925. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  926. If (!(Test-Path $SensorState)) {
  927. New-Item $SensorState
  928. }
  929. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  930. If (!(Test-Path $LocationConfig)) {
  931. New-Item $LocationConfig
  932. }
  933. Set-ItemProperty $LocationConfig Status -Value 0
  934. #Disables People icon on Taskbar
  935. Write-Host "Disabling People icon on Taskbar"
  936. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  937. If (!(Test-Path $People)) {
  938. New-Item $People
  939. }
  940. Set-ItemProperty $People PeopleBand -Value 0
  941. #Disables scheduled tasks that are considered unnecessary
  942. Write-Host "Disabling scheduled tasks"
  943. Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  944. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  945. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  946. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  947. Get-ScheduledTask DmClient | Disable-ScheduledTask
  948. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  949. #Write-Host "Uninstalling Telemetry Windows Updates"
  950. #Uninstalls Some Windows Updates considered to be Telemetry. !WIP!
  951. #Wusa /Uninstall /KB:3022345 /norestart /quiet
  952. #Wusa /Uninstall /KB:3068708 /norestart /quiet
  953. #Wusa /Uninstall /KB:3075249 /norestart /quiet
  954. #Wusa /Uninstall /KB:3080149 /norestart /quiet
  955. Write-Host "Stopping and disabling WAP Push Service"
  956. #Stop and disable WAP Push Service
  957. Stop-Service "dmwappushservice"
  958. Set-Service "dmwappushservice" -StartupType Disabled
  959. Write-Host "Stopping and disabling Diagnostics Tracking Service"
  960. #Disabling the Diagnostics Tracking Service
  961. Stop-Service "DiagTrack"
  962. Set-Service "DiagTrack" -StartupType Disabled
  963. Write-Host "Telemetry has been disabled! `n"
  964. })
  965. $RemoveRegkeys.Add_Click( {
  966. $ErrorActionPreference = 'silentlycontinue'
  967. $Keys = @(
  968. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  969. #Remove Background Tasks
  970. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  971. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  972. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  973. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  974. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  975. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  976. #Windows File
  977. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  978. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  979. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  980. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  981. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  982. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  983. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  984. #Scheduled Tasks to delete
  985. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  986. #Windows Protocol Keys
  987. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  988. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  989. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  990. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  991. #Windows Share Target
  992. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  993. )
  994. #This writes the output of each key it is removing and also removes the keys listed above.
  995. ForEach ($Key in $Keys) {
  996. Write-Host "Removing $Key from registry"
  997. Remove-Item $Key -Recurse
  998. }
  999. Write-Host "Additional bloatware keys have been removed! `n"
  1000. })
  1001. $RemoveOnedrive.Add_Click( {
  1002. Write-Output "Checking for pre-existing files located in the OneDrive folders..."
  1003. Start-Sleep 1
  1004. If (Get-Item -Path "$env:USERPROFILE\OneDrive\*") {
  1005. Write-Output "Files found within the OneDrive folder! Checking to see if a folder named OneDriveBackupFiles exists."
  1006. Start-Sleep 1
  1007. If (Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue) {
  1008. Write-Output "A folder named OneDriveBackupFiles already exists on your desktop. All files from your OneDrive location will be moved to that folder."
  1009. }
  1010. else {
  1011. If (!(Get-Item "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -ErrorAction SilentlyContinue)) {
  1012. Write-Output "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."
  1013. New-item -Path "$env:USERPROFILE\Desktop" -Name "OneDriveBackupFiles"-ItemType Directory -Force
  1014. Write-Output "Successfully created the folder 'OneDriveBackupFiles' on your desktop."
  1015. }
  1016. }
  1017. Start-Sleep 1
  1018. Move-Item -Path "$env:USERPROFILE\OneDrive\*" -Destination "$env:USERPROFILE\Desktop\OneDriveBackupFiles" -Force
  1019. Write-Output "Successfully moved all files from your OneDrive folder to the folder 'OneDriveBackupFiles' on your desktop."
  1020. Start-Sleep 1
  1021. Write-Output "Proceeding with the removal of OneDrive."
  1022. Start-Sleep 1
  1023. }
  1024. Else {
  1025. If (!(Get-Item -Path "$env:USERPROFILE\OneDrive\*")) {
  1026. Write-Output "Either the OneDrive folder does not exist or there are no files to be found in the folder. Proceeding with removal of OneDrive."
  1027. Start-Sleep 1
  1028. }
  1029. }
  1030. Write-Host "Uninstalling OneDrive. Please wait..."
  1031. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  1032. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  1033. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  1034. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  1035. Stop-Process -Name "OneDrive*"
  1036. Start-Sleep 2
  1037. If (!(Test-Path $onedrive)) {
  1038. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  1039. }
  1040. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  1041. Start-Sleep 2
  1042. Write-Host "Stopping explorer"
  1043. Start-Sleep 1
  1044. .\taskkill.exe /F /IM explorer.exe
  1045. Start-Sleep 3
  1046. Write-Host "Removing leftover files"
  1047. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  1048. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  1049. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  1050. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  1051. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  1052. }
  1053. Write-Host "Removing OneDrive from windows explorer"
  1054. If (!(Test-Path $ExplorerReg1)) {
  1055. New-Item $ExplorerReg1
  1056. }
  1057. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  1058. If (!(Test-Path $ExplorerReg2)) {
  1059. New-Item $ExplorerReg2
  1060. }
  1061. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  1062. Write-Host "Restarting Explorer that was shut down before."
  1063. Start-Process explorer.exe -NoNewWindow
  1064. Write-Host "OneDrive has been successfully uninstalled! `n"
  1065. })
  1066. #endregion events }
  1067. #endregion GUI }
  1068. [void]$Form.ShowDialog()