Windows10DebloaterGUI.ps1 68 KB

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