SHARE
TWEET

steam_dota_fix

aveyo Apr 21st, 2017 (edited) 927 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. goto="init" /* %~nx0
  2. :: V7 changes: trigger verify dialog;no longer resets all firewall settings, just Steam and DOTA; clear local Workshop files
  3. :start [ Batch main function ]
  4. echo.
  5. echo   -------------------------------------------------------------
  6. echo  ^|                 AVEYO`S STEAM / DOTA FIX V7.3               ^|
  7. echo  ^|-------------------------------------------------------------^|
  8. echo  ^|        Warning! This will forcefuly close Steam Games       ^|
  9. echo  ^|  Press Alt+F4 to cancel         Always run latest version!  ^|
  10. echo   -------------------------------------------------------------
  11. echo.
  12. timeout /t 10
  13. call :set_dota
  14. echo User = %STEAMDATA%
  15. echo DOTA = %DOTA%
  16. taskkill /t /f /im steam.exe >nul 2>nul
  17. echo Please wait while repairing Steam Service..
  18. set "sservice=%CommonProgramFiles(x86)%\Steam\SteamService.exe" &set "sservice32=%CommonProgramFiles%\Steam\SteamService.exe"
  19. if exist "%STEAMPATH%\bin\SteamService.exe" start "w" /MIN /WAIT "%STEAMPATH%\bin\SteamService.exe" /repair
  20. if not exist "%STEAMPATH%\bin\SteamService.exe" if exist "%sservice%" start "w" /MIN /WAIT "%sservice%" /repair
  21. if not exist "%STEAMPATH%\bin\SteamService.exe" if not exist "%sservice%" start "w" /MIN /WAIT "%sservice32%" /repair
  22. echo Please wait while resetting bcd..
  23. rem bcdedit.exe /set {current} nx OptIn &rem AlwaysOn
  24. (
  25.  bcdedit /deletevalue nointegritychecks
  26.  bcdedit /deletevalue loadoptions
  27.  bcdedit /debug off
  28.  bcdedit /deletevalue nx
  29. ) >nul 2<nul
  30. echo Please wait while resetting Network configuration..
  31. rem netsh advfirewall reset
  32. (
  33.  ipconfig /flushdns
  34.  nbtstat -R
  35.  nbtstat -RR
  36.  netsh advfirewall firewall delete rule name="Dota 2"
  37.  netsh advfirewall firewall delete rule name="Steam"
  38.  netsh advfirewall firewall delete rule name="Steam Web Helper"
  39.  netsh int ipv4 reset
  40.  netsh int ipv6 reset
  41.  netsh winsock reset
  42. ) >nul 2<nul
  43. echo Please wait while removing compatibility options..
  44. set "regkey=Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
  45. for %%a in (HKCU HKLM) do for %%B in (32 64) do (
  46.  reg delete "%%a\%regkey%" /v "%STEAMPATH%\Steam.exe" /f /reg:%%B
  47.  reg delete "%%a\%regkey%" /v "%DOTA%\game\bin\win64\dota2.exe" /f /reg:%%B
  48.  reg delete "%%a\%regkey%" /v "%DOTA%\game\bin\win32\dota2.exe" /f /reg:%%B
  49. ) >nul 2>nul
  50. set "regkey=Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant"
  51. set excluded="%STEAMPATH%\Steam.exe"\0"%DOTA%\game\bin\win64\dota2.exe"\0"%DOTA%\game\bin\win32\dota2.exe"\0
  52. for %%a in (HKCU HKLM) do for %%B in (32 64) do (
  53.  reg add "%%a\%regkey%" /v "ExecutablesToExclude" /t REG_MULTI_SZ /d %excluded% /f /reg:%%B
  54. ) >nul 2>nul
  55. for %%a in (HKCU HKLM) do for %%B in (32 64) do for %%z in (Persisted Store) do (
  56.  reg delete "%%a\%regkey%\%%z" /v "%STEAMPATH%\Steam.exe" /f /reg:%%B
  57.  reg delete "%%a\%regkey%\%%z" /v "%DOTA%\game\bin\win64\dota2.exe" /f /reg:%%B
  58.  reg delete "%%a\%regkey%\%%z" /v "%DOTA%\game\bin\win32\dota2.exe" /f /reg:%%B
  59. ) >nul 2>nul
  60. :: remove image execution options and disable sehop
  61. set "regkey=HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
  62. for %%a in (Steam.exe steamwebhelper.exe dota2.exe) do for %%B in (32 64) do (
  63.  reg delete "%regkey%\%%a" /va /f /reg:%%B
  64.  reg add "%regkey%\%%a" /v "DisableExceptionChainValidation" /t REG_DWORD /d 1 /f /reg:%%B
  65. ) >nul 2>nul
  66. :: remove appverif & memory leak diag
  67. set "regkey=HKLM\Software\Microsoft\RADAR\HeapLeakDetection\DiagnosedApplications"
  68. for %%a in (Steam.exe steamwebhelper.exe dota2.exe) do for %%B in (32 64) do reg delete "%regkey%\%%a" /va /f /reg:%%B >nul 2>nul
  69. echo Please wait while disabling Game DVR..
  70. reg add "HKCU\System\GameConfigStore" /v "GameDVR_Enabled" /t REG_DWORD /d 0 /f >nul 2>nul
  71. reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v "AppCaptureEnabled" /t REG_DWORD /d 0 /f >nul 2>nul
  72. reg add "HKCU\Software\Microsoft\GameBar" /v "AllowAutoGameMode" /t REG_DWORD /d 0 /f >nul 2>nul
  73. :: disable start with windows
  74. reg add "HKCU\Software\Valve\Steam" /v "AlreadyRetriedOfflineMode" /t REG_DWORD /d 1 /f >nul 2>nul
  75. reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "Steam" /f >nul 2>nul
  76. :: steam with launch options shortcut
  77. set "sopts=-console -silent -forceservice -noassert -nocrashmonitor -nobigpicture -single_core -tcp" &rem -udpforce  
  78. call cscript /nologo /e:JScript "%~f0" lnk "%STEAMPATH%\Steam.exe" "%sopts%" "%USERPROFILE%\Desktop\Steam.lnk"
  79.  
  80. rem pause & rem file removal section below
  81.  
  82. echo Please wait while removing current Steam configuration..
  83. set ".=%USERPROFILE%\AppData\Local\Steam"
  84. del /f/s/q "%.%" >nul 2>nul &rmdir /s/q "%.%" >nul 2>nul
  85. cd/d "%STEAMPATH%"
  86. for /f "usebackq tokens=*" %%a in (`dir /a:-D /b ^| findstr /l /i /v "steam.exe"`) do del /f/q "%%a" >nul 2>nul
  87. for /f "tokens=*" %%a in ('dir /a:D /b ^| findstr /i /v steamapps') do del /f/q "%%a" >nul 2>nul &rmdir /s/q "%%a" >nul 2>nul
  88. echo Please wait while removing current DOTA configuration..
  89. cd/d "%DOTA%\game\core"
  90. for %%a in (cfg scripts) do del /f/s/q %%a >nul 2>nul &rmdir /s/q %%a >nul 2>nul
  91. cd/d "%DOTA%\game\dota"
  92. for %%a in (core scripts) do del /f/s/q %%a >nul 2>nul &rmdir /s/q %%a >nul 2>nul
  93. for /f "usebackq tokens=*" %%a in (`dir /a:-D /b ^| findstr /l /i /v ".vpk"`) do del /f/q "%%a" >nul 2>nul
  94. del /f/q cfg\vide*.txt >nul 2>nul
  95. del /f/q cfg\*.vcfg >nul 2>nul
  96. echo Please wait while removing current Workshop files..
  97. for %%a in (workshop downloading temp) do (
  98.  takeown /f "%STEAMAPPS%\%%a" /r /d y >nul 2>nul
  99.  icacls "%STEAMAPPS%\%%a" /reset /t /q >nul 2>nul
  100.  attrib -r "%STEAMAPPS%\%%a" /s /d >nul 2>nul
  101.  del /f/s/q "%STEAMAPPS%\%%a" >nul 2>nul
  102.  rmdir /s/q "%STEAMAPPS%\%%a" >nul 2>nul
  103. )
  104. :: prevent launching the game before verification is finished + force exe refresh
  105. del /f/q "%DOTA%\game\dota\bin\win64\*.dll" >nul 2>nul
  106. del /f/q "%DOTA%\game\dota\bin\win32\*.dll" >nul 2>nul
  107. del /f/q "%DOTA%\game\bin\win64\dota2.exe" >nul 2>nul
  108. del /f/q "%DOTA%\game\bin\win32\dota2.exe" >nul 2>nul
  109. del /f/q "%DOTA%\game\bin\vidcfg.bin" >nul 2>nul
  110. :: clean old crash dump files
  111. del /f/q "%DOTA%\game\bin\win64\*.mdmp" >nul 2>nul
  112. del /f/q "%DOTA%\game\bin\win32\*.mdmp" >nul 2>nul
  113. echo.
  114. echo Please wait while starting Steam with admin rights - you need to login
  115. set launchoptions= -console -forceservice -tcp +app_set_update_flag 570 1 +app_mark_validation 570 1 +app_start_validation 570 1
  116. start "w" "%STEAMPATH%\Steam.exe" %launchoptions% -applaunch 570
  117. timeout /t 20 >nul
  118. echo.
  119. echo Verification of DOTA files will be done automatically on next run
  120. echo Check progress in Steam library, it takes a few minutes
  121. :: done!
  122. call :end DONE! Some changes will take effect after the next restart
  123. goto :eof
  124.  
  125. :: [ Batch utility ]
  126. :set_dota outputs %STEAMPATH% %STEAMAPPS% %STEAMDATA% %DOTA%                       ||:i AveYo:" Override detection below if needed "
  127. set "STEAMPATH=C:\Steam" &set "DOTA=C:\Games\steamapps\common\dota 2 beta"
  128. if not exist "%STEAMPATH%\Steam.exe" call :reg_query "HKCU\Software\Valve\Steam" "SteamPath" STEAMPATH
  129. if not exist "%STEAMPATH%\Steam.exe" call :end ! Cannot find SteamPath in registry
  130. if exist "%DOTA%\game\dota\maps\dota.vpk" set "STEAMAPPS=%DOTA:\common\dota 2 beta=%" &goto :set_steamid
  131. for %%s in ("%STEAMPATH%") do set "STEAMPATH=%%~dpnxs" &set "libfilter=LibraryFolders { TimeNextStatsReport ContentStatsID }"
  132. if not exist "%STEAMPATH%\SteamApps\libraryfolders.vdf" call :end ! Cannot find "%STEAMPATH%\SteamApps\libraryfolders.vdf"
  133. for /f usebackq^ delims^=^"^ tokens^=4 %%s in (`findstr /v "%libfilter%" "%STEAMPATH%\SteamApps\libraryfolders.vdf"`) do (
  134. if exist "%%s\steamapps\appmanifest_570.acf" if exist "%%s\steamapps\common\dota 2 beta\game\dota\maps\dota.vpk" set "libfs=%%s" )
  135. set "STEAMAPPS=%STEAMPATH%\steamapps" &if defined libfs set "STEAMAPPS=%libfs:\\=\%\steamapps"
  136. if not exist "%STEAMAPPS%\common\dota 2 beta\game\dota\maps\dota.vpk" call :end ! Cannot find "%STEAMAPPS%\common\dota 2 beta"
  137. set "DOTA=%STEAMAPPS%\common\dota 2 beta" &cd /d "%STEAMAPPS%\common\dota 2 beta\game\dota"
  138. :set_steamid
  139. call :reg_query "HKCU\Software\Valve\Steam\ActiveProcess" "ActiveUser" STEAMUSER &set /a "STEAMID=STEAMUSER" >nul 2>nul
  140. if defined STEAMID if exist "%STEAMPATH%\userdata\%STEAMID%\config\localconfig.vdf" set "STEAMDATA=%STEAMPATH%\userdata\%STEAMID%"
  141. if not defined STEAMDATA for /f delims^=^ eol^= %%b in ('dir /a:-d /b /o:d /t:w cache_*.soc 2^>nul') do set "usercache=%%~nb"
  142. if not defined STEAMDATA if defined usercache set "STEAMDATA=%steampath%\userdata\%usercache:cache_=%"
  143. if defined STEAMDATA if not exist "%STEAMDATA%\config\localconfig.vdf" set "STEAMDATA=" &rem call :end ! Cannot find STEAMDATA
  144. goto :eof
  145. :reg_query %1:KeyName %2:ValueName %3:OutputVariable %4:other_options[example: "/t REG_DWORD"]
  146. setlocal &for /f "skip=2 delims=" %%s in ('reg query "%~1" /v "%~2" /z 2^>nul') do set "rq=%%s" &call set "rv=%%rq:*)    =%%"
  147. endlocal &call set "%~3=%rv%" &goto :eof                         ||:i AveYo - Usage:" call :reg_query "HKCU\MyKey" "MyValue" MyVar "
  148. :end %1:Message[Delayed termination with status message - prefix with ! to signal failure]
  149. echo. &if "%~1"=="!" ( color 4f & echo ERROR%* &timeout /t 32 &exit ) else echo %* &timeout /t 20 &exit
  150. :noop [does_nothing]
  151. goto :eof
  152.  
  153. :"init" [ Batch entry function ]
  154. @echo off & setlocal disabledelayedexpansion &title AveYo's %~nx0 &color 0B &cls & if "%1"=="_SELF_ADMIN" shift &shift & goto :start
  155. reg query "HKEY_USERS\S-1-5-20\Environment" /v temp 1>nul 2>nul && goto :start || echo Requesting admin rights.. & color 4f
  156. call cscript /nologo /e:JScript "%~f0" get_rights "%1" & exit & goto :eof
  157.  
  158. *//* [ JScript functions ] all lines above are ignored by starting script with a js comment */
  159. function get_rights(fn) {WSH.CreateObject("Shell.Application").ShellExecute(fn,"_SELF_ADMIN "+fn+" "+WSH.Arguments(1),"","runas",1)}
  160. function lnk(exe,param,target) { var lnk=WScript.CreateObject("WScript.Shell").CreateShortcut(target), param=param || '';
  161.   lnk.TargetPath=exe; lnk.Arguments=param; lnk.IconLocation=exe + ",0"; lnk.Save(); }
  162. if (WSH.Arguments.length>=1 && WSH.Arguments(0)=="get_rights") get_rights(WSH.ScriptFullName);
  163. if (WSH.Arguments.length>=1 && WSH.Arguments(0)=="lnk") lnk(WSH.Arguments(1),WSH.Arguments(2),WSH.Arguments(3));
  164. //
RAW Paste Data
Top