Windows10DebloaterGUI.ps1 63 KB

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