Windows10DebloaterGUI.ps1 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  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 CheckService {
  406. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  407. Start-Service -Name dmwappushservice
  408. }
  409. }
  410. Write-Host "Initiating Sysprep"
  411. Begin-SysPrep
  412. Write-Host "Removing bloatware apps."
  413. DebloatAll
  414. DebloatBlacklist
  415. Write-Host "Removing leftover bloatware registry keys."
  416. Remove-Keys
  417. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  418. FixWhitelistedApps
  419. Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  420. Protect-Privacy
  421. #Write-Host "Stopping Edge from taking over as the default PDF Viewer."
  422. #Stop-EdgePDF
  423. Write-Host "Finished all tasks. `n"
  424. } )
  425. $RemoveBloatNoBlacklist.Add_Click( {
  426. $ErrorActionPreference = 'silentlycontinue'
  427. #This function finds any AppX/AppXProvisioned package and uninstalls it, except for Freshpaint, Windows Calculator, Windows Store, and Windows Photos.
  428. #Also, to note - This does NOT remove essential system services/software/etc such as .NET framework installations, Cortana, Edge, etc.
  429. #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.
  430. param (
  431. [switch]$Debloat, [switch]$SysPrep
  432. )
  433. Function Begin-SysPrep {
  434. $ErrorActionPreference = 'silentlycontinue'
  435. param([switch]$SysPrep)
  436. Write-Host -Message ('Starting Sysprep Fixes')
  437. # Disable Windows Store Automatic Updates
  438. Write-Host -Message "Adding Registry key to Disable Windows Store Automatic Updates"
  439. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"
  440. If (!(Test-Path $registryPath)) {
  441. Mkdir $registryPath -ErrorAction SilentlyContinue
  442. New-ItemProperty $registryPath -Name AutoDownload -Value 2
  443. }
  444. Else {
  445. Set-ItemProperty $registryPath -Name AutoDownload -Value 2
  446. }
  447. #Stop WindowsStore Installer Service and set to Disabled
  448. Write-Host -Message ('Stopping InstallService')
  449. Stop-Service InstallService
  450. Write-Host -Message ('Setting InstallService Startup to Disabled')
  451. & Set-Service -Name InstallService -StartupType Disabled
  452. }
  453. #Creates a PSDrive to be able to access the 'HKCR' tree
  454. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  455. Function Start-Debloat {
  456. $ErrorActionPreference = 'silentlycontinue'
  457. param([switch]$Debloat)
  458. #Removes AppxPackages
  459. #Credit to Reddit user /u/GavinEke for a modified version of my whitelist code
  460. [regex]$WhitelistedApps = 'Microsoft.ScreenSketch|Microsoft.Paint3D|Microsoft.MSPaint|Microsoft.WindowsCalculator|Microsoft.WindowsStore|Microsoft.MicrosoftStickyNotes|Microsoft.WindowsSoundRecorder|Microsoft.Windows.Photos|CanonicalGroupLimited.UbuntuonWindows'
  461. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue
  462. # Run this again to avoid error on 1803 or having to reboot.
  463. Get-AppxPackage -AllUsers | Where-Object {$_.Name -NotMatch $WhitelistedApps} | Remove-AppxPackage -ErrorAction SilentlyContinue
  464. Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -NotMatch $WhitelistedApps} | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
  465. }
  466. Function Remove-Keys {
  467. $ErrorActionPreference = 'silentlycontinue'
  468. Param([switch]$Debloat)
  469. #These are the registry keys that it will delete.
  470. $Keys = @(
  471. #Remove Background Tasks
  472. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  473. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  474. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  475. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  476. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  477. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  478. #Windows File
  479. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  480. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  481. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  482. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  483. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  484. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  485. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  486. #Scheduled Tasks to delete
  487. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  488. #Windows Protocol Keys
  489. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  490. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  491. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  492. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  493. #Windows Share Target
  494. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  495. )
  496. #This writes the output of each key it is removing and also removes the keys listed above.
  497. ForEach ($Key in $Keys) {
  498. Write-Host "Removing $Key from registry"
  499. Remove-Item $Key -Recurse -ErrorAction SilentlyContinue
  500. }
  501. }
  502. Function Protect-Privacy {
  503. $ErrorActionPreference = 'silentlycontinue'
  504. Param([switch]$Debloat)
  505. #Creates a PSDrive to be able to access the 'HKCR' tree
  506. New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  507. #Disables Windows Feedback Experience
  508. Write-Host "Disabling Windows Feedback Experience program"
  509. $Advertising = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo'
  510. If (Test-Path $Advertising) {
  511. Set-ItemProperty $Advertising -Name Enabled -Value 0 -Verbose
  512. }
  513. #Stops Cortana from being used as part of your Windows Search Function
  514. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  515. $Search = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search'
  516. If (Test-Path $Search) {
  517. Set-ItemProperty $Search -Name AllowCortana -Value 0 -Verbose
  518. }
  519. #Stops the Windows Feedback Experience from sending anonymous data
  520. Write-Host "Stopping the Windows Feedback Experience program"
  521. $Period1 = 'HKCU:\Software\Microsoft\Siuf'
  522. $Period2 = 'HKCU:\Software\Microsoft\Siuf\Rules'
  523. $Period3 = 'HKCU:\Software\Microsoft\Siuf\Rules\PeriodInNanoSeconds'
  524. If (!(Test-Path $Period3)) {
  525. mkdir $Period1 -ErrorAction SilentlyContinue
  526. mkdir $Period2 -ErrorAction SilentlyContinue
  527. mkdir $Period3 -ErrorAction SilentlyContinue
  528. New-ItemProperty $Period3 -Name PeriodInNanoSeconds -Value 0 -Verbose -ErrorAction SilentlyContinue
  529. }
  530. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  531. #Prevents bloatware applications from returning
  532. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  533. If (!(Test-Path $registryPath)) {
  534. Mkdir $registryPath -ErrorAction SilentlyContinue
  535. New-ItemProperty $registryPath -Name DisableWindowsConsumerFeatures -Value 1 -Verbose -ErrorAction SilentlyContinue
  536. }
  537. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  538. $Holo = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic'
  539. If (Test-Path $Holo) {
  540. Set-ItemProperty $Holo -Name FirstRunSucceeded -Value 0 -Verbose
  541. }
  542. #Disables live tiles
  543. Write-Host "Disabling live tiles"
  544. $Live = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications'
  545. If (!(Test-Path $Live)) {
  546. mkdir $Live -ErrorAction SilentlyContinue
  547. New-ItemProperty $Live -Name NoTileApplicationNotification -Value 1 -Verbose
  548. }
  549. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  550. Write-Host "Turning off Data Collection"
  551. $DataCollection = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection'
  552. If (Test-Path $DataCollection) {
  553. Set-ItemProperty $DataCollection -Name AllowTelemetry -Value 0 -Verbose
  554. }
  555. #Disables People icon on Taskbar
  556. Write-Host "Disabling People icon on Taskbar"
  557. $People = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People'
  558. If (!(Test-Path $People)) {
  559. mkdir $People -ErrorAction SilentlyContinue
  560. New-ItemProperty $People -Name PeopleBand -Value 0 -Verbose
  561. }
  562. #Disables suggestions on start menu
  563. Write-Host "Disabling suggestions on the Start Menu"
  564. $Suggestions = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
  565. If (Test-Path $Suggestions) {
  566. Set-ItemProperty $Suggestions -Name SystemPaneSuggestionsEnabled -Value 0 -Verbose
  567. }
  568. #Loads the registry keys/values below into the NTUSER.DAT file which prevents the apps from redownloading. Credit to a60wattfish
  569. reg load HKU\Default_User C:\Users\Default\NTUSER.DAT
  570. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SystemPaneSuggestionsEnabled -Value 0
  571. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name PreInstalledAppsEnabled -Value 0
  572. Set-ItemProperty -Path Registry::HKU\Default_User\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name OemPreInstalledAppsEnabled -Value 0
  573. reg unload HKU\Default_User
  574. #Disables scheduled tasks that are considered unnecessary
  575. Write-Host "Disabling scheduled tasks"
  576. #Get-ScheduledTask -TaskName XblGameSaveTaskLogon | Disable-ScheduledTask -ErrorAction SilentlyContinue
  577. Get-ScheduledTask -TaskName XblGameSaveTask | Disable-ScheduledTask -ErrorAction SilentlyContinue
  578. Get-ScheduledTask -TaskName Consolidator | Disable-ScheduledTask -ErrorAction SilentlyContinue
  579. Get-ScheduledTask -TaskName UsbCeip | Disable-ScheduledTask -ErrorAction SilentlyContinue
  580. Get-ScheduledTask -TaskName DmClient | Disable-ScheduledTask -ErrorAction SilentlyContinue
  581. Get-ScheduledTask -TaskName DmClientOnScenarioDownload | Disable-ScheduledTask -ErrorAction SilentlyContinue
  582. }
  583. #This includes fixes by xsisbest
  584. Function FixWhitelistedApps {
  585. Param([switch]$Debloat)
  586. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.MSPaint, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.MicrosoftStickyNotes, Microsoft.WindowsSoundRecorder, Microsoft.Windows.Photos)) {
  587. #Credit to abulgatz for the 4 lines of code
  588. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  589. Get-AppxPackage -allusers Microsoft.MSPaint | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  590. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  591. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  592. Get-AppxPackage -allusers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  593. Get-AppxPackage -allusers Microsoft.WindowsSoundRecorder | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  594. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  595. }
  596. }
  597. Function CheckService {
  598. Param([switch]$Debloat)
  599. If (Get-Service -Name dmwappushservice | Where-Object {$_.Status -eq "Stopped"}) {
  600. Start-Service -Name dmwappushservice
  601. }
  602. }
  603. Begin-SysPrep
  604. Write-Host "Removing bloatware apps."
  605. Start-Debloat
  606. Write-Host "Removing leftover bloatware registry keys."
  607. Remove-Keys
  608. Write-Host "Checking to see if any Whitelisted Apps were removed, and if so re-adding them."
  609. FixWhitelistedApps
  610. Write-Host "Stopping telemetry, disabling unneccessary scheduled tasks, and preventing bloatware from returning."
  611. Protect-Privacy
  612. #Write-Host "Stopping Edge from taking over as the default PDF Viewer."
  613. Write-Host "Checking to make sure that the service 'dmwappushservice' has been started."
  614. CheckService
  615. Write-Host "Finished all tasks. `n"
  616. })
  617. $RevertChange.Add_Click( {
  618. $ErrorActionPreference = 'silentlycontinue'
  619. #This function will revert the changes you made when running the Start-Debloat function.
  620. #This line reinstalls all of the bloatware that was removed
  621. Get-AppxPackage -AllUsers | ForEach {Add-AppxPackage -Verbose -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  622. #Tells Windows to enable your advertising information.
  623. Write-Host "Re-enabling key to show advertisement information"
  624. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  625. If (Test-Path $Advertising) {
  626. Set-ItemProperty $Advertising Enabled -Value 1
  627. }
  628. #Enables Cortana to be used as part of your Windows Search Function
  629. Write-Host "Re-enabling Cortana to be used in your Windows Search"
  630. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  631. If (Test-Path $Search) {
  632. Set-ItemProperty $Search AllowCortana -Value 1
  633. }
  634. #Re-enables the Windows Feedback Experience for sending anonymous data
  635. Write-Host "Re-enabling Windows Feedback Experience"
  636. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  637. If (!(Test-Path $Period)) {
  638. New-Item $Period
  639. }
  640. Set-ItemProperty $Period PeriodInNanoSeconds -Value 1
  641. #Enables bloatware applications
  642. Write-Host "Adding Registry key to allow bloatware apps to return"
  643. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  644. If (!(Test-Path $registryPath)) {
  645. New-Item $registryPath
  646. }
  647. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 0
  648. #Changes Mixed Reality Portal Key 'FirstRunSucceeded' to 1
  649. Write-Host "Setting Mixed Reality Portal value to 1"
  650. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  651. If (Test-Path $Holo) {
  652. Set-ItemProperty $Holo FirstRunSucceeded -Value 1
  653. }
  654. #Re-enables live tiles
  655. Write-Host "Enabling live tiles"
  656. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  657. If (!(Test-Path $Live)) {
  658. New-Item $Live
  659. }
  660. Set-ItemProperty $Live NoTileApplicationNotification -Value 0
  661. #Re-enables data collection
  662. Write-Host "Re-enabling data collection"
  663. $DataCollection = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  664. If (!(Test-Path $DataCollection)) {
  665. New-Item $DataCollection
  666. }
  667. Set-ItemProperty $DataCollection AllowTelemetry -Value 1
  668. #Re-enables People Icon on Taskbar
  669. Write-Host "Enabling People icon on Taskbar"
  670. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  671. If (!(Test-Path $People)) {
  672. New-Item $People
  673. }
  674. Set-ItemProperty $People PeopleBand -Value 1
  675. #Re-enables suggestions on start menu
  676. Write-Host "Enabling suggestions on the Start Menu"
  677. $Suggestions = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  678. If (!(Test-Path $Suggestions)) {
  679. New-Item $Suggestions
  680. }
  681. Set-ItemProperty $Suggestions SystemPaneSuggestionsEnabled -Value 1
  682. #Re-enables scheduled tasks that were disabled when running the Debloat switch
  683. Write-Host "Enabling scheduled tasks that were disabled"
  684. Get-ScheduledTask XblGameSaveTaskLogon | Enable-ScheduledTask
  685. Get-ScheduledTask XblGameSaveTask | Enable-ScheduledTask
  686. Get-ScheduledTask Consolidator | Enable-ScheduledTask
  687. Get-ScheduledTask UsbCeip | Enable-ScheduledTask
  688. Get-ScheduledTask DmClient | Enable-ScheduledTask
  689. Get-ScheduledTask DmClientOnScenarioDownload | Enable-ScheduledTask
  690. Write-Host "Re-enabling and starting WAP Push Service"
  691. #Enable and start WAP Push Service
  692. Set-Service "dmwappushservice" -StartupType Automatic
  693. Start-Service "dmwappushservice"
  694. Write-Host "Re-enabling and starting the Diagnostics Tracking Service"
  695. #Enabling the Diagnostics Tracking Service
  696. Set-Service "DiagTrack" -StartupType Automatic
  697. Start-Service "DiagTrack"
  698. Write-Host "Done reverting changes! `n"
  699. })
  700. $FixWhitelist.Add_Click( {
  701. $ErrorActionPreference = 'silentlycontinue'
  702. If (!(Get-AppxPackage -AllUsers | Select Microsoft.Paint3D, Microsoft.WindowsCalculator, Microsoft.WindowsStore, Microsoft.Windows.Photos)) {
  703. #Credit to abulgatz for these 4 lines of code
  704. Get-AppxPackage -allusers Microsoft.Paint3D | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  705. Get-AppxPackage -allusers Microsoft.WindowsCalculator | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  706. Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  707. Get-AppxPackage -allusers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  708. }
  709. Write-Host "Whitelisted apps were either fixed or re-added. `n"
  710. })
  711. $DisableCortana.Add_Click( {
  712. $ErrorActionPreference = 'silentlycontinue'
  713. Write-Host "Disabling Cortana"
  714. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  715. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  716. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  717. If (!(Test-Path $Cortana1)) {
  718. New-Item $Cortana1
  719. }
  720. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 0
  721. If (!(Test-Path $Cortana2)) {
  722. New-Item $Cortana2
  723. }
  724. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 1
  725. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 1
  726. If (!(Test-Path $Cortana3)) {
  727. New-Item $Cortana3
  728. }
  729. Set-ItemProperty $Cortana3 HarvestContacts -Value 0
  730. Write-Host "Cortana has been disabled. `n"
  731. })
  732. $StopEdgePDFTakeover.Add_Click( {
  733. $ErrorActionPreference = 'silentlycontinue'
  734. #Stops edge from taking over as the default .PDF viewer
  735. Write-Host "Stopping Edge from taking over as the default .PDF viewer"
  736. $NoPDF = "HKCR:\.pdf"
  737. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  738. $NoWithList = "HKCR:\.pdf\OpenWithList"
  739. If (!(Get-ItemProperty $NoPDF NoOpenWith)) {
  740. New-ItemProperty $NoPDF NoOpenWith
  741. }
  742. If (!(Get-ItemProperty $NoPDF NoStaticDefaultVerb)) {
  743. New-ItemProperty $NoPDF NoStaticDefaultVerb
  744. }
  745. If (!(Get-ItemProperty $NoProgids NoOpenWith)) {
  746. New-ItemProperty $NoProgids NoOpenWith
  747. }
  748. If (!(Get-ItemProperty $NoProgids NoStaticDefaultVerb)) {
  749. New-ItemProperty $NoProgids NoStaticDefaultVerb
  750. }
  751. If (!(Get-ItemProperty $NoWithList NoOpenWith)) {
  752. New-ItemProperty $NoWithList NoOpenWith
  753. }
  754. If (!(Get-ItemProperty $NoWithList NoStaticDefaultVerb)) {
  755. New-ItemProperty $NoWithList NoStaticDefaultVerb
  756. }
  757. #Appends an underscore '_' to the Registry key for Edge
  758. $Edge = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  759. If (Test-Path $Edge) {
  760. Set-Item $Edge AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_
  761. }
  762. Write-Host "Edge should no longer take over as the default .PDF. `n"
  763. })
  764. $EnableCortana.Add_Click( {
  765. $ErrorActionPreference = 'silentlycontinue'
  766. Write-Host "Re-enabling Cortana"
  767. $Cortana1 = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"
  768. $Cortana2 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"
  769. $Cortana3 = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"
  770. If (!(Test-Path $Cortana1)) {
  771. New-Item $Cortana1
  772. }
  773. Set-ItemProperty $Cortana1 AcceptedPrivacyPolicy -Value 1
  774. If (!(Test-Path $Cortana2)) {
  775. New-Item $Cortana2
  776. }
  777. Set-ItemProperty $Cortana2 RestrictImplicitTextCollection -Value 0
  778. Set-ItemProperty $Cortana2 RestrictImplicitInkCollection -Value 0
  779. If (!(Test-Path $Cortana3)) {
  780. New-Item $Cortana3
  781. }
  782. Set-ItemProperty $Cortana3 HarvestContacts -Value 1
  783. Write-Host "Cortana has been enabled! `n"
  784. })
  785. $EnableEdgePDFTakeover.Add_Click( {
  786. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  787. $ErrorActionPreference = 'silentlycontinue'
  788. Write-Host "Setting Edge back to default"
  789. $NoPDF = "HKCR:\.pdf"
  790. $NoProgids = "HKCR:\.pdf\OpenWithProgids"
  791. $NoWithList = "HKCR:\.pdf\OpenWithList"
  792. #Sets edge back to default
  793. If (Get-ItemProperty $NoPDF NoOpenWith) {
  794. Remove-ItemProperty $NoPDF NoOpenWith
  795. }
  796. If (Get-ItemProperty $NoPDF NoStaticDefaultVerb) {
  797. Remove-ItemProperty $NoPDF NoStaticDefaultVerb
  798. }
  799. If (Get-ItemProperty $NoProgids NoOpenWith) {
  800. Remove-ItemProperty $NoProgids NoOpenWith
  801. }
  802. If (Get-ItemProperty $NoProgids NoStaticDefaultVerb) {
  803. Remove-ItemProperty $NoProgids NoStaticDefaultVerb
  804. }
  805. If (Get-ItemProperty $NoWithList NoOpenWith) {
  806. Remove-ItemProperty $NoWithList NoOpenWith
  807. }
  808. If (Get-ItemProperty $NoWithList NoStaticDefaultVerb) {
  809. Remove-ItemProperty $NoWithList NoStaticDefaultVerb
  810. }
  811. #Removes an underscore '_' from the Registry key for Edge
  812. $Edge2 = "HKCR:\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723_"
  813. If (Test-Path $Edge2) {
  814. Set-Item $Edge2 AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723
  815. }
  816. Write-Host "Edge will now be able to be used for .PDF. `n"
  817. })
  818. $DisableTelemetry.Add_Click( {
  819. $ErrorActionPreference = 'silentlycontinue'
  820. #Disables Windows Feedback Experience
  821. Write-Host "Disabling Windows Feedback Experience program"
  822. $Advertising = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"
  823. If (Test-Path $Advertising) {
  824. Set-ItemProperty $Advertising Enabled -Value 0
  825. }
  826. #Stops Cortana from being used as part of your Windows Search Function
  827. Write-Host "Stopping Cortana from being used as part of your Windows Search Function"
  828. $Search = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  829. If (Test-Path $Search) {
  830. Set-ItemProperty $Search AllowCortana -Value 0
  831. }
  832. #Disables Web Search in Start Menu
  833. Write-Host "Disabling Bing Search in Start Menu"
  834. $WebSearch = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"
  835. Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" BingSearchEnabled -Value 0
  836. If (!(Test-Path $WebSearch)) {
  837. New-Item $WebSearch
  838. }
  839. Set-ItemProperty $WebSearch DisableWebSearch -Value 1
  840. #Stops the Windows Feedback Experience from sending anonymous data
  841. Write-Host "Stopping the Windows Feedback Experience program"
  842. $Period = "HKCU:\Software\Microsoft\Siuf\Rules"
  843. If (!(Test-Path $Period)) {
  844. New-Item $Period
  845. }
  846. Set-ItemProperty $Period PeriodInNanoSeconds -Value 0
  847. #Prevents bloatware applications from returning and removes Start Menu suggestions
  848. Write-Host "Adding Registry key to prevent bloatware apps from returning"
  849. $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
  850. $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
  851. If (!(Test-Path $registryPath)) {
  852. New-Item $registryPath
  853. }
  854. Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1
  855. If (!(Test-Path $registryOEM)) {
  856. New-Item $registryOEM
  857. }
  858. Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0
  859. Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0
  860. Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0
  861. Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0
  862. Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0
  863. Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0
  864. #Preping mixed Reality Portal for removal
  865. Write-Host "Setting Mixed Reality Portal value to 0 so that you can uninstall it in Settings"
  866. $Holo = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Holographic"
  867. If (Test-Path $Holo) {
  868. Set-ItemProperty $Holo FirstRunSucceeded -Value 0
  869. }
  870. #Disables Wi-fi Sense
  871. Write-Host "Disabling Wi-Fi Sense"
  872. $WifiSense1 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting"
  873. $WifiSense2 = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots"
  874. $WifiSense3 = "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config"
  875. If (!(Test-Path $WifiSense1)) {
  876. New-Item $WifiSense1
  877. }
  878. Set-ItemProperty $WifiSense1 Value -Value 0
  879. If (!(Test-Path $WifiSense2)) {
  880. New-Item $WifiSense2
  881. }
  882. Set-ItemProperty $WifiSense2 Value -Value 0
  883. Set-ItemProperty $WifiSense3 AutoConnectAllowedOEM -Value 0
  884. #Disables live tiles
  885. Write-Host "Disabling live tiles"
  886. $Live = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications"
  887. If (!(Test-Path $Live)) {
  888. New-Item $Live
  889. }
  890. Set-ItemProperty $Live NoTileApplicationNotification -Value 1
  891. #Turns off Data Collection via the AllowTelemtry key by changing it to 0
  892. Write-Host "Turning off Data Collection"
  893. $DataCollection1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  894. $DataCollection2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"
  895. $DataCollection3 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"
  896. If (Test-Path $DataCollection1) {
  897. Set-ItemProperty $DataCollection1 AllowTelemetry -Value 0
  898. }
  899. If (Test-Path $DataCollection2) {
  900. Set-ItemProperty $DataCollection2 AllowTelemetry -Value 0
  901. }
  902. If (Test-Path $DataCollection3) {
  903. Set-ItemProperty $DataCollection3 AllowTelemetry -Value 0
  904. }
  905. #Disabling Location Tracking
  906. Write-Host "Disabling Location Tracking"
  907. $SensorState = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}"
  908. $LocationConfig = "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration"
  909. If (!(Test-Path $SensorState)) {
  910. New-Item $SensorState
  911. }
  912. Set-ItemProperty $SensorState SensorPermissionState -Value 0
  913. If (!(Test-Path $LocationConfig)) {
  914. New-Item $LocationConfig
  915. }
  916. Set-ItemProperty $LocationConfig Status -Value 0
  917. #Disables People icon on Taskbar
  918. Write-Host "Disabling People icon on Taskbar"
  919. $People = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People"
  920. If (!(Test-Path $People)) {
  921. New-Item $People
  922. }
  923. Set-ItemProperty $People PeopleBand -Value 0
  924. #Disables scheduled tasks that are considered unnecessary
  925. Write-Host "Disabling scheduled tasks"
  926. Get-ScheduledTask XblGameSaveTaskLogon | Disable-ScheduledTask
  927. Get-ScheduledTask XblGameSaveTask | Disable-ScheduledTask
  928. Get-ScheduledTask Consolidator | Disable-ScheduledTask
  929. Get-ScheduledTask UsbCeip | Disable-ScheduledTask
  930. Get-ScheduledTask DmClient | Disable-ScheduledTask
  931. Get-ScheduledTask DmClientOnScenarioDownload | Disable-ScheduledTask
  932. #Write-Host "Uninstalling Telemetry Windows Updates"
  933. #Uninstalls Some Windows Updates considered to be Telemetry. !WIP!
  934. #Wusa /Uninstall /KB:3022345 /norestart /quiet
  935. #Wusa /Uninstall /KB:3068708 /norestart /quiet
  936. #Wusa /Uninstall /KB:3075249 /norestart /quiet
  937. #Wusa /Uninstall /KB:3080149 /norestart /quiet
  938. Write-Host "Stopping and disabling WAP Push Service"
  939. #Stop and disable WAP Push Service
  940. Stop-Service "dmwappushservice"
  941. Set-Service "dmwappushservice" -StartupType Disabled
  942. Write-Host "Stopping and disabling Diagnostics Tracking Service"
  943. #Disabling the Diagnostics Tracking Service
  944. Stop-Service "DiagTrack"
  945. Set-Service "DiagTrack" -StartupType Disabled
  946. Write-Host "Telemetry has been disabled! `n"
  947. })
  948. $RemoveRegkeys.Add_Click( {
  949. $ErrorActionPreference = 'silentlycontinue'
  950. $Keys = @(
  951. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  952. #Remove Background Tasks
  953. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  954. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  955. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  956. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  957. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  958. "HKCR:\Extensions\ContractId\Windows.BackgroundTasks\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  959. #Windows File
  960. "HKCR:\Extensions\ContractId\Windows.File\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  961. #Registry keys to delete if they aren't uninstalled by RemoveAppXPackage/RemoveAppXProvisionedPackage
  962. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\46928bounde.EclipseManager_2.2.4.51_neutral__a5h4egax66k6y"
  963. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  964. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  965. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  966. "HKCR:\Extensions\ContractId\Windows.Launch\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  967. #Scheduled Tasks to delete
  968. "HKCR:\Extensions\ContractId\Windows.PreInstalledConfigTask\PackageId\Microsoft.MicrosoftOfficeHub_17.7909.7600.0_x64__8wekyb3d8bbwe"
  969. #Windows Protocol Keys
  970. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  971. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.PPIProjection_10.0.15063.0_neutral_neutral_cw5n1h2txyewy"
  972. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.15063.0.0_neutral_neutral_cw5n1h2txyewy"
  973. "HKCR:\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.XboxGameCallableUI_1000.16299.15.0_neutral_neutral_cw5n1h2txyewy"
  974. #Windows Share Target
  975. "HKCR:\Extensions\ContractId\Windows.ShareTarget\PackageId\ActiproSoftwareLLC.562882FEEB491_2.6.18.18_neutral__24pqs290vpjk0"
  976. )
  977. #This writes the output of each key it is removing and also removes the keys listed above.
  978. ForEach ($Key in $Keys) {
  979. Write-Host "Removing $Key from registry"
  980. Remove-Item $Key -Recurse
  981. }
  982. Write-Host "Additional bloatware keys have been removed! `n"
  983. })
  984. $RemoveOnedrive.Add_Click( {
  985. Write-Host "Uninstalling OneDrive. Please wait..."
  986. New-PSDrive HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
  987. $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  988. $ExplorerReg1 = "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  989. $ExplorerReg2 = "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
  990. Stop-Process -Name "OneDrive*"
  991. Start-Sleep 2
  992. If (!(Test-Path $onedrive)) {
  993. $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  994. }
  995. Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  996. Start-Sleep 2
  997. Write-Host "Stopping explorer"
  998. Start-Sleep 1
  999. .\taskkill.exe /F /IM explorer.exe
  1000. Start-Sleep 3
  1001. Write-Host "Removing leftover files"
  1002. Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse
  1003. Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse
  1004. Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse
  1005. If (Test-Path "$env:SYSTEMDRIVE\OneDriveTemp") {
  1006. Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse
  1007. }
  1008. Write-Host "Removing OneDrive from windows explorer"
  1009. If (!(Test-Path $ExplorerReg1)) {
  1010. New-Item $ExplorerReg1
  1011. }
  1012. Set-ItemProperty $ExplorerReg1 System.IsPinnedToNameSpaceTree -Value 0
  1013. If (!(Test-Path $ExplorerReg2)) {
  1014. New-Item $ExplorerReg2
  1015. }
  1016. Set-ItemProperty $ExplorerReg2 System.IsPinnedToNameSpaceTree -Value 0
  1017. Write-Host "Restarting Explorer that was shut down before."
  1018. Start-Process explorer.exe -NoNewWindow
  1019. Write-Host "OneDrive has been successfully uninstalled! `n"
  1020. })
  1021. #endregion events }
  1022. #endregion GUI }
  1023. [void]$Form.ShowDialog()