Advertisement
aveyo

undo_windows_gaming_steam_dota_fix

Dec 1st, 2017
3,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 14.56 KB | None | 0 0
  1. @goto=init %~nx0
  2. :: Batch designed for Windows 10 - compatible with Windows 7
  3. ::----------------------------------------------------------------------------------------------------------------------------------
  4. :about %1:[0c = red-on-black: Batch was run as user, 0b = cyan-on-black Batch was run as admin]
  5. ::----------------------------------------------------------------------------------------------------------------------------------
  6. call :clearline 1
  7. call :color %1. "      ---------------------------------------------------------------------  "
  8. call :color %1. "     :                UNDO_WINDOWS_GAMING_STEAM_DOTA_FIX V9.5              : "
  9. call :color %1. "     :---------------------------------------------------------------------: "
  10. call :color %1. "     : -GameDVR -Xbox -GameBarPresenceWriter -FullscreenOpt AppCompatFlags : "
  11. call :color %1. "     :                                                                     : "
  12. call :color %1. "     : Press Alt+F4 to cancel                    Always run latest version : "
  13. call :color %1. "      ---------------------------------------------------------------------  "
  14. call :color %1. " "
  15. exit/b
  16.  
  17. ::----------------------------------------------------------------------------------------------------------------------------------
  18. :main [ Batch main function ]
  19. ::----------------------------------------------------------------------------------------------------------------------------------
  20. title AveYo's UNDO WINDOWS GAMING + STEAM DOTA FIX
  21. color 07
  22. call :about 0b
  23. ::timeout /t 10
  24.  
  25. call :reg_query "HKCU\Environment" "Fix choices" CHOICES
  26. if defined CHOICES echo  Last choices: %CHOICES%
  27.  
  28. ::----------------------------------------------------------------------------------------------------------------------------------
  29. call :mcolor 07 " Reset " 70 " AMD DVR / Nvidia GFE / ShadowPlay " 07. " blocking.. "
  30. :: amd dvr task restore
  31. set "tasks=%SystemRoot%\System32\Tasks"
  32. if exist "%tasks%\StartDVR.bak" (
  33.  pushd "%tasks%"
  34.  icacls StartDVR /grant "Everyone:(OI)(CI)W"
  35.  rd /s /q StartDVR
  36.  copy /y StartDVR.bak StartDVR
  37.  popd
  38. ) >nul 2>nul
  39. set "regkey=HKCU\SOFTWARE\AMD\CN"
  40. reg delete "%regkey%" /v "OverclockEnabled" /f >nul 2>nul
  41. reg delete "%regkey%\ANALYTICS" /v "AnalyticsUploadDays" /f >nul 2>nul
  42. set "regkey=HKCU\Software\ATI\ACE\Settings\Runtime"
  43. reg delete "%regkey%\Graphics\OverDrive5" /v "OverclockEnabled_DEF" /f >nul 2>nul
  44. :: amd dvr / relive / telemetry executable restore
  45. call :UnBlockExecution "amddvr amdow"
  46. :: nvidia gfe / shadowplay / telemetry executable restore
  47. call :UnBlockExecution "nvstreamer NvTelemetryContainer NvContainer" &rem nvnodejslauncher NVNetworkService
  48.  
  49. call :mcolor 07 " Reset " 70 " Game DVR " 07. " to defaults.. "
  50. (
  51.  reg add "HKCU\Software\Microsoft\GameBar" /v "AllowAutoGameMode" /t REG_DWORD /d "1" /f
  52.  reg add "HKCU\Software\Microsoft\GameBar" /v "ShowStartupPanel" /t REG_DWORD /d "1" /f
  53.  reg add "HKCU\Software\Microsoft\GameBar" /v "UseNexusForGameBarEnabled" /t REG_DWORD /d "1" /f
  54.  reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v "AppCaptureEnabled" /t REG_DWORD /d "1" /f
  55.  reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v "AudioCaptureEnabled" /t REG_DWORD /d "1" /f
  56.  reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v "CursorCaptureEnabled" /t REG_DWORD /d "1" /f
  57.  reg add "HKCU\System\GameConfigStore" /v "GameDVR_Enabled" /t REG_DWORD /d "1" /f
  58.  reg add "HKLM\Software\Policies\Microsoft\Windows\GameDVR" /v "AllowgameDVR" /t REG_DWORD /d "1" /f
  59. ) >nul 2>nul
  60. call :UnBlockExecution "bcastdvr GamePanel"
  61.  
  62. :: - GameBar - alternative disable method
  63. set "regkey=Microsoft\WindowsRuntime\ActivatableClassId\Windows.Media.Capture.Internal.AppCaptureShell"
  64. reg add "HKLM\SOFTWARE\%regkey%" /v "ActivationType" /t REG_DWORD /d 1 /f >nul 2>nul
  65. reg add "HKLM\SOFTWARE\WOW6432Node\%regkey%" /v "ActivationType" /t REG_DWORD /d 1 /f >nul 2>nul
  66.  
  67. ::----------------------------------------------------------------------------------------------------------------------------------
  68. call :mcolor 07 " Reset " 70 " Xbox " 07. " to defaults.. "
  69. (
  70.  reg add "HKLM\System\CurrentControlSet\Services\xbgm" /v "Start" /t REG_DWORD /d "3" /f
  71.  schtasks /Change /TN "Microsoft\XblGameSave\XblGameSaveTask" /ENABLE
  72.  schtasks /Change /TN "Microsoft\XblGameSave\XblGameSaveTaskLogon" /ENABLE
  73.  sc config XblAuthManager start= auto
  74.  sc config XblGameSave start= auto
  75.  sc config XboxGipSvc start= auto
  76.  sc config XboxNetApiSvc start= auto
  77. ) >nul 2>nul
  78.  
  79. ::----------------------------------------------------------------------------------------------------------------------------------
  80. call :mcolor 07 " Reset " 70 " GameBarPresenceWriter " 07. " to defaults.. "
  81. set "regkey=Microsoft\WindowsRuntime\ActivatableClassId\Windows.Gaming.GameBar.PresenceServer.Internal.PresenceWriter"
  82. reg add "HKLM\SOFTWARE\%regkey%" /v "ActivationType" /t REG_DWORD /d 1 /f /reg:64 >nul 2>nul
  83. reg add "HKLM\SOFTWARE\%regkey%" /v "ActivationType" /t REG_DWORD /d 1 /f /reg:32 >nul 2>nul
  84. call :UnBlockExecution "GameBarPresenceWriter"
  85.  
  86. ::----------------------------------------------------------------------------------------------------------------------------------
  87. call :mcolor 07 " Reset " 70 " Fullscreen so-called optimizations " 07. " to defaults.. "
  88. set "regkey=Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
  89. for %%a in (HKCU HKLM) do for %%B in (32 64) do reg delete "%%a\%regkey%" /va /f /reg:%%B >nul 2>nul
  90.  
  91. ::----------------------------------------------------------------------------------------------------------------------------------
  92. call :mcolor 07 " Reset " 70 " AppCompatFlags " 07. " to defaults.. "
  93. set "regkey=Software\Policies\Microsoft\Windows\AppCompat"
  94. for %%a in (HKCU HKLM) do (
  95.  reg delete "%%a\%regkey%" /v "DisablePCA" /f
  96.  reg delete "%%a\%regkey%" /v "DisableUAR" /f
  97.  reg delete "%%a\%regkey%" /v "AITEnable" /f
  98. ) >nul 2>nul
  99. :: reset tdr limits
  100. set "regkey=HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers"
  101. (
  102.  reg add "%regkey%" /v TdrLevel /t REG_DWORD /d 0x3 /f
  103.  reg add "%regkey%" /v TdrDelay /t REG_DWORD /d 0x2 /f
  104.  reg add "%regkey%" /v TdrDdiDelay /t REG_DWORD /d 0x5 /f
  105.  reg add "%regkey%" /v TdrLimitCount /t REG_DWORD /d 0x5 /f
  106.  reg add "%regkey%" /v TdrLimitTime /t REG_DWORD /d 0x3c /f
  107. ) >nul 2>nul
  108.  
  109. :: Generic windows gaming fixes end here, Steam and Dota fixes below
  110.  
  111. ::----------------------------------------------------------------------------------------------------------------------------------
  112. call :set_steam
  113. call :set_dota
  114. :: reset steam and dota fullscreen so-called optimization and dpi scaling..
  115. set "regkey=Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
  116. for %%# in ("%STEAMPATH%\Steam.exe" "%DOTA%\bin\win64\dota2.exe" "%DOTA%\bin\win32\dota2.exe") do (
  117.  for %%a in (HKCU HKLM) do for %%B in (32 64) do reg delete "%%a\%regkey%" /v "%%~#" /f /reg:%%B
  118. ) >nul 2>nul
  119. :: reset steam and dota image file execution
  120. set "exes=Steam.exe steamwebhelper.exe GameOverlayUI.exe dota2.exe"
  121. set "regkey=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
  122. for %%a in (%exes%) do for %%B in (32 64) do reg delete "%regkey%\%%a" /va /f /reg:%%B >nul 2>nul
  123. :: remove Steam_tweak lnk
  124. del /f /q "%USERPROFILE%\Desktop\Steam_tweak.lnk" 2>nul
  125.  
  126. :done
  127. ::----------------------------------------------------------------------------------------------------------------------------------
  128. call :mcolor b0 " DONE " 0b " Some changes will take effect after the next PC restart "
  129. timeout /t 12 >nul
  130. exit
  131.  
  132. ::----------------------------------------------------------------------------------------------------------------------------------
  133. :: Utility functions
  134. ::----------------------------------------------------------------------------------------------------------------------------------
  135. :UnBlockExecution %1:[executable names without extension, like "bcastdvr GamePanel" ]
  136. set "regkey=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
  137. for %%a in (%~1) do for %%B in (32 64) do (
  138.  reg delete "%regkey%\%%a.exe" /v Debugger /f /reg:%%B
  139. ) >nul 2>nul
  140. exit/b
  141.  
  142. :set_steam [OUTPUTS] STEAMPATH STEAMDATA STEAMID                                      AveYo : Override detection below if needed
  143. set "STEAMPATH=D:\Steam"
  144. if not exist "%STEAMPATH%\Steam.exe" call :reg_query STEAMPATH "HKCU\SOFTWARE\Valve\Steam" "SteamPath"
  145. set "STEAMDATA=" & if defined STEAMPATH for %%. in ("%STEAMPATH%") do set "STEAMPATH=%%~dpnx."
  146. if not exist "%STEAMPATH%\Steam.exe" call :end # Cannot find SteamPath in registry
  147. call :reg_query ACTIVEUSER "HKCU\SOFTWARE\Valve\Steam\ActiveProcess" "ActiveUser" & set/a "STEAMID=ACTIVEUSER" >nul 2>nul
  148. if exist "%STEAMPATH%\userdata\%STEAMID%\config\localconfig.vdf" set "STEAMDATA=%STEAMPATH%\userdata\%STEAMID%"
  149. if not defined STEAMDATA for /f "delims=" %%. in ('dir "%STEAMPATH%\userdata" /b/o:d/t:w/s 2^>nul') do set "ACTIVEUSER=%%~dp."
  150. if not defined STEAMDATA for /f "delims=\" %%. in ("%ACTIVEUSER:*\userdata\=%") do set "STEAMID=%%."
  151. if exist "%STEAMPATH%\userdata\%STEAMID%\config\localconfig.vdf" set "STEAMDATA=%STEAMPATH%\userdata\%STEAMID%"
  152. exit/b
  153.  
  154. :set_dota [OUTPUTS] STEAMAPPS DOTA CONTENT                                            AveYo : Override detection below if needed
  155. set "DOTA=D:\Games\steamapps\common\dota 2 beta\game"
  156. if exist "%DOTA%\dota\maps\dota.vpk" set "STEAMAPPS=%DOTA:\common\dota 2 beta=%" & exit/b
  157. set "libfilter=LibraryFolders { TimeNextStatsReport ContentStatsID }"
  158. if not exist "%STEAMPATH%\SteamApps\libraryfolders.vdf" call :end # Cannot find "%STEAMPATH%\SteamApps\libraryfolders.vdf"
  159. for /f usebackq^ delims^=^"^ tokens^=4 %%s in (`findstr /v "%libfilter%" "%STEAMPATH%\SteamApps\libraryfolders.vdf"`) do (
  160. if exist "%%s\steamapps\appmanifest_570.acf" if exist "%%s\steamapps\common\dota 2 beta\game\dota\pak01_*.vpk" set "libfs=%%s")
  161. set "STEAMAPPS=%STEAMPATH%\steamapps" & if defined libfs set "STEAMAPPS=%libfs:\\=\%\steamapps"
  162. if not exist "%STEAMAPPS%\common\dota 2 beta\game\dota\maps\dota.vpk" call :end # Missing "%STEAMAPPS%\common\dota 2 beta\game"
  163. set "DOTA=%STEAMAPPS%\common\dota 2 beta\game" & set "CONTENT=%STEAMAPPS%\common\dota 2 beta\content"
  164. exit/b
  165.  
  166. :reg_query [USAGE] call :reg_query ResultVar "HKCU\KeyName" "ValueName"
  167. (for /f "skip=2 delims=" %%s in ('reg query "%~2" /v "%~3" /z 2^>nul') do set ".=%%s" & call set "%~1=%%.:*)    =%%") & exit/b
  168.  
  169. ::----------------------------------------------------------------------------------------------------------------------------------
  170. :: Core functions
  171. ::----------------------------------------------------------------------------------------------------------------------------------
  172. :set_macros [OUTPUTS] %[BS]%=BackSpace %[CR]%=CarriageReturn %[GL]%=Glue/NonBreakingSpace %[DEL]%=DelChar %[DEL7]%=DelCharX7
  173. pushd "%TEMP%" & echo=WSH.Echo(String.fromCharCode(160))>` & for /f %%# in ('cscript //E:JScript //nologo `') do set "[GL]=%%#"
  174. for /f %%# in ('echo prompt $H ^| cmd') do set "[BS]=%%#" & for /f %%# in ('copy /z "%~dpf0" nul') do set "[CR]=%%#"
  175. for /f "tokens=2 delims=1234567890" %%# in ('shutdown /?^|findstr /bc:"E"') do set "[TAB]=%%#"
  176. set/p "=-"<nul>` &set "ECHOP=<nul set/p =%[BS]%" &set "[DEL]=%[BS]%%[GL]%%[BS]%" &call set "[DEL3]=%%[DEL]%%%%[DEL]%%%%[DEL]%%"
  177. set "[L]=-%[DEL]%\..\%[DEL3]%"&set "[J]=-%[DEL]%/..\%[DEL3]%"&set "[DEL6]=%[DEL3]%%[DEL3]%" &set "LABEL=echo. &call :color 70. "
  178. set "INFO=call :color b0 " INFO " &echo" & set "WARN=call :color e0 " WARN " &echo" & set "ERROR=call :color cf " ERROR " &echo"
  179. exit/b                                       &REM AveYo - :clearline and :color depend on this, initialize with call :set_macros
  180.  
  181. :clearline Number[how many lines above to delete - macro designed for Windows 10 but adjusted to work under 7 too]
  182. ( if not defined [DEL] call :set_macros ) &setlocal enableDelayedExpansion & set "[LINE]=%[CR]%" & set "[LINE7]=" & set "[COL]="
  183. for /f "skip=4 tokens=2 delims=:" %%a in ('mode con') do for %%c in (%%a) do if not defined [COL] call set "[COL]=%%c"
  184. set/a "[C7]=2+(%[COL]%+7)/8"&for /l %%i in (1,1,%[COL]%) do call set "[CLR]=%%[CLR]%%%[GL]%"&call set "[LINE]=%[DEL]%%%[LINE]%%"
  185. for /L %%a in (1,1,%[C7]%) do call set "[LINE7]=%%[LINE7]%%%[BS]%"
  186. ver | find "10." >nul & if errorlevel 1 (for /L %%i in (1,1,%1) do echo;%[TAB]%%[LINE7]%%[CLR]% & echo;%[TAB]%%[LINE7]% ) else (
  187. for /l %%i in (1,1,%1) do <nul set/p "=![LINE]!" )
  188. endlocal & exit/b                                                                                  &REM Usage: call :clearline 2
  189.  
  190. :color BgFg.[one or both of hexpair can be _ as defcolor, optional . use newline] text["text with spaces"]
  191. setlocal enableDelayedExpansion &set "bf=%~1"&set "tx=%~2"&set "tx=-%[BS]%!tx:\=%[L]%!"&set "tx=!tx:/=%[J]%!"&set "tx=!tx:"=\"!"
  192. set "bf=!bf: =!" &set "bc=!bf:~0,1!" &set "fc=!bf:~1,1!" &set "nl=!bf:~2,1!"&set "bc=!bc:_=%BackClr%!"&set "fc=!fc:_=%TextClr%!"
  193. pushd "%TEMP%" & findstr /p /r /a:!bc!!fc! "^^-" "!tx!\..\`" nul &<nul set/p "=%[DEL]%%[DEL6]%" &popd &if defined nl echo/%[GL]%
  194. endlocal & exit/b                    &REM AveYo - Usage: call :color fc Hello & call :color _c " fancy " & call :color cf. World
  195.  
  196. :mcolor BgFg. "only-quoted-text1" BgFg. "only-quoted-text2" etc.
  197. set "-mc~=" & for %%C in (%*) do if "%%C"=="%%~C" (call set "-mc~=%%-mc~%% & call :color %%C") else call set "-mc~=%%-mc~%% %%C"
  198. echo. %-mc~% & exit/b                                       &REM AveYo - Usage: call :mcolor fc "Hello" _c " fancy " cf. "World"
  199.  
  200. :end %1:Message[Delayed termination with status message - prefix with # to signal failure]
  201. echo. & if "%~1"=="#" ( %ERROR% %* & timeout /t 32 & exit ) else %INFO%  %* & timeout /t 20 & exit
  202.  
  203. ::----------------------------------------------------------------------------------------------------------------------------------
  204. :init Console preferences                                           sets color table and prevents mouseclicks pausing the script
  205. ::----------------------------------------------------------------------------------------------------------------------------------
  206. @echo off & setlocal &set "BackClr=0" &set "TextClr=7" &set "Columns=40" &set "Lines=120" &set "Buff=9999" &call :set_macros 2>nul
  207. rem reg delete "HKCU\Console\init" /va /f >nul 2>nul
  208. rem if not "%1"=="init" ( cd/d %~dp0 & start "init" "%~f0" init & exit/b ) else goto :main  &rem " Simple no admin self-restart "
  209. if "%1"=="init" shift &shift & goto :main &rem " Admin self-restart flag found, jump to :main "
  210. reg query "HKEY_USERS\S-1-5-20\Environment" /v temp 1>nul 2>nul && goto :main || call :about 0c & echo  Requesting admin rights..
  211. powershell -noprofile -c "Start-Process cmd.exe -ArgumentList '/c \"%~f0\" init' -verb RunAs"
  212. exit
  213. ::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement