Windows10DebloaterGUI.ps1 65 KB

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