Windows10DebloaterGUI.ps1 63 KB

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