2
0

Windows10DebloaterGUI.ps1 68 KB

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