Windows10DebloaterGUI.ps1 68 KB

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