Advertisement
aveyo

dota_lan_share

Feb 21st, 2017
2,637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 7.71 KB | None | 0 0
  1. /* 2>nul&goto init %~nx0
  2. :start [ Batch main ] Script should be Awesome, but if it does not work for you, contact me on reddit
  3. echo.
  4. echo   -------------------------------------------------------------
  5. echo  ^|                    AVEYO`S DOTA_LAN_SHARE                   ^|
  6. echo  ^|-------------------------------------------------------------^|
  7. echo  ^|  Run this once on the PC that will be sharing updated game  ^|
  8. echo  ^|  Steam and DOTA should be set to enable automatic updates   ^|
  9. echo  ^|  Generated "DOTA_LAN" folder contains only essential files  ^|
  10. echo  ^|                                                             ^|
  11. echo  ^|  Other PCs should have DOTA automatic updates disabled      ^|
  12. echo  ^|  and when needing updates, connect to your DOTA_LAN share   ^|
  13. echo  ^|  and run the generated "dota_lan_update.bat" from there     ^|
  14. echo   -------------------------------------------------------------
  15. echo.
  16. call :wait 10 Starting
  17. call :set_dota
  18. md "%steamapps%\DOTA_LAN\steamapps\common\dota 2 beta\game" 1>nul 2>nul
  19. set "dota_lan=%steamapps%\DOTA_LAN" & set "dota_lan_game=%steamapps%\DOTA_LAN\steamapps\common\dota 2 beta\game"
  20. echo  SHARED FOLDER = %DOTA_LAN% & echo    Do not directly modify content there!
  21. echo    Instead, delete DOTA_LAN folder and re-run %~nx0 & echo.
  22. :: export dota_lan_update.bat
  23. pushd "%dota_lan%" & (call :writer "dota_lan_update.bat") & popd
  24. if exist "%dota_lan%\dota_lan_update.bat" (set rez=OK!) else set rez=FAIL!
  25. echo  Creating dota_lan_update.bat - %rez%
  26. :: junctions
  27. for %%s in (bin core dota dota_russian dota_schinese dota_koreana) do mklink /j "%dota_lan_game%\%%s" "%dota%\%%s" 1>nul 2>nul
  28. if exist "%dota_lan_game%\dota\maps\dota.vpk" (set rez=OK!) else set rez=FAIL!
  29. echo  Creating junctions to common\dota 2 beta\game\ - %rez%
  30. :: hard links
  31. mklink /h "%dota_lan%\steamapps\appmanifest_570.acf" "%steamapps%\appmanifest_570.acf" 1>nul 2>nul
  32. if exist "%dota_lan%\steamapps\appmanifest_570.acf" (set rez=OK!) else set rez=FAIL!
  33. echo  Creating hard link to appmanifest_570.acf - %rez%
  34. :: (re)sharing DOTA_LAN
  35. net share DOTA_LAN /Y /delete 1>nul 2>nul
  36. net share DOTA_LAN="%dota_lan%" /remark:"Run dota_lan_update.bat" 1>nul 2>nul
  37. if exist "\\%COMPUTERNAME%\DOTA_LAN" (set rez=OK!) else set rez=FAIL!
  38. echo  Creating share \\%COMPUTERNAME%\DOTA_LAN - %rez%
  39. :: done!
  40. call :end DONE!
  41. goto :eof
  42.  
  43. :attachments [ Batch attachments ] export attachment file as is using writer function, instead of echoing every line to generate it
  44. :::dota_lan_update.bat:::
  45. @echo off & cd /d c:\ & setlocal disabledelayedexpansion & title AveYo's %~nx0 & color 0B & cls
  46. echo.
  47. echo   -------------------------------------------------------------
  48. echo  ^|                    AVEYO`S DOTA_LAN_UPDATE                  ^|
  49. echo  ^|-------------------------------------------------------------^|
  50. echo  ^|  Directly run on PCs needing update from this LAN share     ^|
  51. echo  ^|  Steam and DOTA should be set to disable automatic updates  ^|
  52. echo  ^|  Script will not update non-essential and personal files    ^|
  53. echo  ^|                                                             ^|
  54. echo  ^|  Please wait for the script to finish, it will close itself ^|
  55. echo   -------------------------------------------------------------
  56. echo.
  57. call :wait 5 Starting
  58. call :set_dota
  59. :::exp:::
  60. set "src=\\%computername%\DOTA_LAN"
  61. :::noexp:::
  62. set "dst=%steamapps%"
  63. set "xd=cfg guides replays screenshots"
  64. set "xf=*.mdmp *.soc *.vcfg condump*.txt console.log server_log.txt rich_presence*.txt"
  65. set "log=%UserProfile%\Desktop\dota_lan_update.log"
  66. set "dotacfg=common\dota 2 beta\game\dota\cfg"
  67. if exist "%src%" (set rez=OK!) else set rez=FAIL!
  68. echo  Checking share %src% - %rez%
  69. if not exist "%src%" call :end # Cannot update, %src% not found
  70. robocopy "%src%\steamapps\%dotacfg%" "%dst%\%dotacfg%" user_keys_default.vcfg /Z 1>nul 2>nul
  71. robocopy "%src%\steamapps\common" "%dst%\common" /E /Z /J /SL /MT /XF %xf% /XD %xd% /XO /NS /NC /NP /NFL /NDL & rem /LOG:"%log%"
  72. echo  Overwriting appmanifest_570.acf and restarting Steam
  73. taskkill /im steam.exe /t /f 1>nul 2>nul
  74. robocopy "%src%\steamapps" "%dst%" appmanifest_570.acf /Z 1>nul 2>nul
  75. set extra_options=-forceservice -nocrashmonitor -tcp -complete_install_via_http -single_core -no-dwrite -disable-winh264 -vrdisable
  76. start "w" "%steampath%\Steam.exe" -silent -console %extra_options%
  77. call :end DONE!
  78. endlocal & goto :eof
  79.  
  80. :set_dota [ Batch shared functions ] - used by both main script and the dota_lan_update.bat attachment so no need to duplicate them
  81. rem set "steamapps=D:\STEAM LIBRARY\steamapps" & rem uncomment and adjust this line to override steamapps detection
  82. rem set "dota=D:\STEAM LIBRARY\steamapps\common\dota 2 beta\game" & rem uncomment and adjust this line to override dota detection
  83. set "steampath=c:\Program Files (x86)\Steam"
  84. rem goto :eof & rem uncomment to override steampath detection
  85. if not exist "%steampath%" call :get_reg "HKCU\SOFTWARE\Valve\Steam" "SteamPath" steampath
  86. if not exist "%steampath%" call :end # Cannot find SteamPath in registry HKCU\SOFTWARE\Valve\Steam!
  87. for %%s in ("%steampath%") do set "steampath=%%~dpns" & set "libfilter=LibraryFolders { TimeNextStatsReport ContentStatsID }"
  88. if not exist "%steampath%\SteamApps\libraryfolders.vdf" call :end # Cannot find Steam cfg %steampath%\SteamApps\libraryfolders.vdf!
  89. for /f usebackq^ delims^=^"^ tokens^=4 %%s in (`findstr /v "%libfilter%" "%steampath%\SteamApps\libraryfolders.vdf"`) do (
  90. if exist "%%s\steamapps\appmanifest_570.acf" if exist "%%s\steamapps\common\dota 2 beta\game\dota\maps\dota.vpk" set "libfs=%%s")
  91. set "steamapps=%steampath%\steamapps"
  92. if defined libfs set "steamapps=%libfs:\\=\%\steamapps"
  93. if not exist "%steamapps%\common\dota 2 beta\game\dota\maps\dota.vpk" call :end # Cannot find DOTA - %steamapps%\common\dota 2 beta!
  94. set "dota=%steamapps%\common\dota 2 beta\game" & goto :eof
  95. :get_reg Params: 1=KeyName 2=ValueName 3=TargetVariable
  96. for /f "usebackq delims=? eol=*" %%s in (`reg query "%~1" /v "%~2"`) do set "_r_=%%s" & call set "_r_=%%_r_:    =?%%"
  97. for /f "delims=? tokens=3* eol=*" %%s in ("%_r_%") do call set "%~3=%%s" & set "_r_=" & goto :eof
  98. :wait Params: 1=Seconds 2=Message
  99. setlocal enabledelayedexpansion &if not defined x1337cr for /f %%a in ('copy /z "%~dpf0" nul') do set "x1337cr=%%a"
  100. (for /l %%i in (%1,-1,1) do <NUL SET /P "=_%2 in %%i !x1337cr!" &ping -n 2 localhost >nul 2>&1) & endlocal & goto :eof
  101. :end Params: 1=Message - start with # to signal error
  102. (if "%1"=="#" COLOR 7c) &echo. &echo  %* &(call :wait 9 Closing) &echo/             &(if "%1"=="#" exit) &endlocal &color &goto :eof
  103. :::eof:::
  104.  
  105. :init [ Batch main functions ]
  106. @echo off & setlocal disabledelayedexpansion &title AveYo's %~nx0 &color 0B &cls & if "%1"=="_SELF_ADMIN" shift &shift & goto :start
  107. reg query "HKEY_USERS\S-1-5-20\Environment" /v temp 1>nul 2>nul && goto :start || echo Requesting admin rights.. & color 7c
  108. call cscript /nologo /e:JScript "%~f0" get_rights "%1" & exit & goto :eof
  109. :writer Params: 1=Filename - exports content from :::Filename::: to :::eof::: - expands variables from :::exp::: to :::noexp::: line
  110. <nul set /p "=">%1 & set "_w=" & set "_e=" & for /f "tokens=1* delims=]" %%r in ('call find.exe /v /n "" "%~f0"') do (
  111. (if "%%s"==":::%~1:::" set _w=)&(if "%%s"==":::eof:::" set _w=)&(if "%%s"==":::exp:::" set _e=1)&(if "%%s"==":::noexp:::" set _e=)
  112. if defined _w (if defined _e (call echo/%%s>>%1) else echo/%%s>>%1) else if "%%s"==":::%~1:::" set _w=1)
  113. goto :eof
  114.  
  115. *//* [ JScript functions ] all lines above are ignored by starting script with a js comment */
  116. function get_rights(fn) {WSH.CreateObject("Shell.Application").ShellExecute(fn,"_SELF_ADMIN "+fn+" "+WSH.Arguments(1),"","runas",1)}
  117. if (WSH.Arguments.length>=1) {if (WSH.Arguments(0)=="get_rights") get_rights(WSH.ScriptFullName)}
  118. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement