Windows10DebloaterGUI.ps1 63 KB

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