Advertisement
aveyo

ms-gamebar-annoyance

Dec 27th, 2024
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.73 KB | Gaming | 0 0
  1. @(set ^ "0=%~f0" -des ') &set 1=%*& powershell -nop -c iex(out-string -i (gc -lit $env:0)) & exit /b ')
  2. # AveYo: fix annoyance after uninstalling Xbox, AveYo 2024.12.27
  3.  
  4. $n0 = 'ms-gamebar-annoyance'
  5. $s0 = 'active'
  6. if (gp Registry::HKCR\ms-gamebar NoOpenWith -ea 0) { $s0 = 'inactive' }
  7.  
  8. #:: Args / Dialog - to skip the prompt can use commandline parameters or rename script: ms-gamebar-annoyance disable.bat
  9. $do = ''; $cl = @{0 = 'enable'; 1 = 'disable'; 2 = 'cancel'} ; if (!$env:0) {$env:0 = "$pwd\.pasted"}
  10. foreach ($a in $cl.Values) {if ("$(split-path $env:0 -leaf) $env:1" -like "*$a*") {$do = $a} }
  11. if ($do -eq '') {
  12.   $choice = (new-object -ComObject Wscript.Shell).Popup("state: $s0  -  No to disable", 0, $n0, 0x1043)
  13.   if ($choice -eq 2) {$do = $cl[2]} elseif ($choice -eq 7) {$do = $cl[1]} else {$do = $cl[0]} ; $env:1 = $do
  14.   if ($do -eq 'cancel') {return}
  15. }
  16.  
  17. $toggle = (0,1)[$do -eq 'enable']
  18. sp "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" "AppCaptureEnabled" $toggle -type dword -force -ea 0
  19. sp "HKCU:\System\GameConfigStore" "GameDVR_Enabled" $toggle -type dword -force -ea 0
  20.  
  21. $cc = {
  22.   [Console]::Title = "$($args[2]) $($args[1])"
  23.   $toggle = (0,1)[($args[1]) -eq 'enable']
  24.   sp "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" "AppCaptureEnabled" $toggle -type dword -force -ea 0
  25.   sp "HKCU:\System\GameConfigStore" "GameDVR_Enabled" $toggle -type dword -force -ea 0
  26.   "ms-gamebar","ms-gamebarservices","ms-gamingoverlay" |foreach {
  27.     if (!(test-path "Registry::HKCR\$_\shell")) {ni "Registry::HKCR\$_\shell" -force >''}
  28.     if (!(test-path "Registry::HKCR\$_\shell\open")) {ni "Registry::HKCR\$_\shell\open" -force >''}
  29.     if (!(test-path "Registry::HKCR\$_\shell\open\command")) {ni "Registry::HKCR\$_\shell\open\command" -force}
  30.     sp "Registry::HKCR\$_" "(Default)" "URL:$_" -force
  31.     sp "Registry::HKCR\$_" "URL Protocol" "" -force
  32.     if ($toggle -eq 0) {
  33.       sp "Registry::HKCR\$_" "NoOpenWith" "" -force
  34.       sp "Registry::HKCR\$_\shell\open\command" "(Default)" "`"$env:SystemRoot\System32\systray.exe`"" -force
  35.     } else {
  36.       rp "Registry::HKCR\$_" "NoOpenWith" -force -ea 0
  37.       ri "Registry::HKCR\$_\shell" -rec -force -ea 0
  38.     }
  39.   }
  40.   start ms-gamebar://annoyance # AveYo: test if working
  41. }
  42.  
  43. if ([Security.Principal.WindowsIdentity]::GetCurrent().Groups.Value -notcontains 'S-1-5-32-544') {
  44.   write-host " Requesting ADMIN rights.. " -fore Black -back Yellow; sleep 2
  45.   sp HKCU:\Volatile*\* $n0 ".{$cc} '$($env:0-replace"'","''")' '$($env:1-replace"'","''")' '$n0'" -force -ea 0
  46.   start powershell  -args "-nop -c iex(gp Registry::HKU\S-1-5-21*\Volatile*\* '$n0' -ea 0).'$n0'" -verb runas
  47. } else {. $cc "$env:0" "$env:1" "$n0" }    
  48.  
  49. $Press_Enter_if_pasted_in_powershell
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement