Created
July 30, 2026 16:07
-
-
Save dot-mike/e01ec1f40dbbbbbe0ef2c511509046bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Fix the ms-gamebar / ms-gamingoverlay "you'll need a new app" nag after uninstalling Xbox. | |
| # Usage: .\fix-gamebar.ps1 apply (or 'restore', or omit for a Yes/No/Cancel prompt) | |
| param([ValidateSet('apply','restore','cancel')][string]$Action) | |
| $id = 'ms-gamebar-annoyance' | |
| # Current state: is the fix already applied? (checkmark next to the matching choice) | |
| $check = [char]0x2713 | |
| if (Get-ItemProperty Registry::HKCR\ms-gamebar NoOpenWith -ErrorAction SilentlyContinue) { | |
| $applyMark = $check; $restoreMark = '' | |
| } else { | |
| $applyMark = ''; $restoreMark = $check | |
| } | |
| # Prompt if no action given on the command line | |
| if (-not $Action) { | |
| $shell = New-Object -ComObject Wscript.Shell | |
| # 0x1043 = Yes/No/Cancel + question icon + default Cancel; returns 6=Yes 7=No 2=Cancel | |
| $choice = $shell.Popup("Yes to apply $applyMark - No to restore $restoreMark", 0, $id, 0x1043) | |
| $Action = @{6='apply'; 7='restore'; 2='cancel'}[$choice] | |
| } | |
| if ($null -eq $Action -or $Action -eq 'cancel') { return } | |
| $toggle = if ($Action -eq 'apply') { 0 } else { 1 } # apply disables GameDVR, restore re-enables it | |
| # Per-user Game DVR settings (current, possibly non-admin, user) | |
| Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" AppCaptureEnabled $toggle -Type DWord -Force -ErrorAction SilentlyContinue | |
| Set-ItemProperty "HKCU:\System\GameConfigStore" GameDVR_Enabled $toggle -Type DWord -Force -ErrorAction SilentlyContinue | |
| # Admin work: rewrite the ms-gamebar* URL protocol handlers (needs elevation) | |
| $adminWork = { | |
| $action = $args[0]; $id = $args[1] | |
| [Console]::Title = "$id $action" | |
| $toggle = if ($action -eq 'apply') { 0 } else { 1 } | |
| Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" AppCaptureEnabled $toggle -Type DWord -Force -ErrorAction SilentlyContinue | |
| Set-ItemProperty "HKCU:\System\GameConfigStore" GameDVR_Enabled $toggle -Type DWord -Force -ErrorAction SilentlyContinue | |
| foreach ($proto in 'ms-gamebar','ms-gamebarservices','ms-gamingoverlay') { | |
| $key = "Registry::HKCR\$proto" | |
| foreach ($sub in 'shell','shell\open','shell\open\command') { | |
| if (!(Test-Path "$key\$sub")) { New-Item "$key\$sub" -Force > $null } | |
| } | |
| Set-ItemProperty $key '(Default)' "URL:$proto" -Force | |
| Set-ItemProperty $key 'URL Protocol' '' -Force | |
| if ($action -eq 'apply') { | |
| Set-ItemProperty $key NoOpenWith '' -Force | |
| Set-ItemProperty "$key\shell\open\command" '(Default)' "`"$env:SystemRoot\System32\systray.exe`"" -Force | |
| } else { | |
| Remove-ItemProperty $key NoOpenWith -Force -ErrorAction SilentlyContinue | |
| Remove-Item "$key\shell" -Recurse -Force -ErrorAction SilentlyContinue | |
| } | |
| } | |
| Start-Process ms-gamebar://annoyance # test link; with the fix applied it silently does nothing | |
| } | |
| # Run $adminWork elevated (or directly if already admin) | |
| $isAdmin = [Security.Principal.WindowsIdentity]::GetCurrent().Groups.Value -contains 'S-1-5-32-544' | |
| if ($isAdmin) { | |
| . $adminWork $Action $id | |
| } else { | |
| Write-Host " '$id' $Action : Requesting ADMIN rights.. " -ForegroundColor Black -BackgroundColor Yellow | |
| # Pass the scriptblock across the UAC boundary via a volatile (reboot-cleared) registry value | |
| Set-ItemProperty HKCU:\Volatile*\* $id ".{$adminWork} '$Action' '$id'" -Force -ErrorAction SilentlyContinue | |
| Start-Process powershell -Verb RunAs -ArgumentList "-nop -c iex(gp Registry::HKU\S-1-5-21*\Volatile*\* '$id' -ea 0).'$id'" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment