-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathundo_gamebar.bat
More file actions
87 lines (77 loc) · 2.85 KB
/
Copy pathundo_gamebar.bat
File metadata and controls
87 lines (77 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@echo off
REM ============================================================================
REM undo_gamebar.bat - reverses fix_gamebar.bat exactly.
REM
REM fix_gamebar.bat records the ORIGINAL state under
REM HKCU\Software\KeyAxis\GameBarBackup before touching anything. This script
REM puts it all back:
REM * protocol handlers - deleted ONLY if they did not exist beforehand
REM * GameDVR values - restored to their previous value, or deleted if
REM they didn't exist before
REM * the backup key itself is removed afterwards
REM
REM Per-user (HKCU), no admin needed. The KeyAxis uninstaller runs this
REM automatically with /silent.
REM ============================================================================
setlocal EnableDelayedExpansion
set "QUIET="
if /i "%~1"=="/silent" set "QUIET=1"
set "BK=HKCU\Software\KeyAxis\GameBarBackup"
set "BKDIR=%LOCALAPPDATA%\KeyAxis\gamebar_backup"
reg query "%BK%" /v Saved >nul 2>&1
if errorlevel 1 (
if not defined QUIET (
echo.
echo Nothing to undo - no KeyAxis backup found.
echo.
pause
)
exit /b 0
)
if not defined QUIET (
echo.
echo Restoring the Game Bar settings you had before...
echo.
)
for %%P in (ms-gamebar ms-gamingoverlay ms-gamebarservices) do call :RestoreKey %%P
call :RestoreDword "HKCU\System\GameConfigStore" GameDVR_Enabled gcs_GameDVR_Enabled
call :RestoreDword "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" AppCaptureEnabled gdvr_AppCaptureEnabled
REM Remove the backup: the registry record, the exported .reg files, then the
REM parent key. Nothing of ours is left behind.
reg delete "%BK%" /f >nul 2>&1
reg delete "HKCU\Software\KeyAxis" /f >nul 2>&1
if exist "%BKDIR%" rmdir /s /q "%BKDIR%" >nul 2>&1
if not defined QUIET (
echo Reverted. Windows Game Bar behaviour is back to how it was.
echo.
pause
)
exit /b 0
REM ---------------------------------------------------------------- helpers --
:RestoreKey
REM %1 = protocol name.
REM existed=0 -> we created it, so remove it.
REM existed=1 -> the user already had one and we overwrote its value; drop
REM ours and re-import their original export.
set "EX="
for /f "tokens=2,*" %%A in ('reg query "%BK%" /v "existed_%~1" 2^>nul ^| findstr /i /c:"existed_"') do set "EX=%%B"
if "!EX!"=="0" (
reg delete "HKCU\Software\Classes\%~1" /f >nul 2>&1
) else if "!EX!"=="1" (
if exist "%BKDIR%\%~1.reg" (
reg delete "HKCU\Software\Classes\%~1" /f >nul 2>&1
reg import "%BKDIR%\%~1.reg" >nul 2>&1
)
)
exit /b 0
:RestoreDword
REM %1 = key %2 = value name %3 = backup value name
set "OLD="
for /f "tokens=2,*" %%A in ('reg query "%BK%" /v %~3 2^>nul ^| findstr /i /c:"%~3"') do set "OLD=%%B"
if not defined OLD exit /b 0
if /i "!OLD!"=="ABSENT" (
reg delete %1 /v %~2 /f >nul 2>&1
) else (
reg add %1 /f /v %~2 /t REG_DWORD /d !OLD! >nul 2>&1
)
exit /b 0