Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 2>nul&goto init %~nx0
- :start [ Batch main ] Script should be Awesome, but if it does not work for you, contact me on reddit
- echo.
- echo -------------------------------------------------------------
- echo ^| AVEYO`S DOTA_LAN_SHARE ^|
- echo ^|-------------------------------------------------------------^|
- echo ^| Run this once on the PC that will be sharing updated game ^|
- echo ^| Steam and DOTA should be set to enable automatic updates ^|
- echo ^| Generated "DOTA_LAN" folder contains only essential files ^|
- echo ^| ^|
- echo ^| Other PCs should have DOTA automatic updates disabled ^|
- echo ^| and when needing updates, connect to your DOTA_LAN share ^|
- echo ^| and run the generated "dota_lan_update.bat" from there ^|
- echo -------------------------------------------------------------
- echo.
- call :wait 10 Starting
- call :set_dota
- md "%steamapps%\DOTA_LAN\steamapps\common\dota 2 beta\game" 1>nul 2>nul
- set "dota_lan=%steamapps%\DOTA_LAN" & set "dota_lan_game=%steamapps%\DOTA_LAN\steamapps\common\dota 2 beta\game"
- echo SHARED FOLDER = %DOTA_LAN% & echo Do not directly modify content there!
- echo Instead, delete DOTA_LAN folder and re-run %~nx0 & echo.
- :: export dota_lan_update.bat
- pushd "%dota_lan%" & (call :writer "dota_lan_update.bat") & popd
- if exist "%dota_lan%\dota_lan_update.bat" (set rez=OK!) else set rez=FAIL!
- echo Creating dota_lan_update.bat - %rez%
- :: junctions
- 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
- if exist "%dota_lan_game%\dota\maps\dota.vpk" (set rez=OK!) else set rez=FAIL!
- echo Creating junctions to common\dota 2 beta\game\ - %rez%
- :: hard links
- mklink /h "%dota_lan%\steamapps\appmanifest_570.acf" "%steamapps%\appmanifest_570.acf" 1>nul 2>nul
- if exist "%dota_lan%\steamapps\appmanifest_570.acf" (set rez=OK!) else set rez=FAIL!
- echo Creating hard link to appmanifest_570.acf - %rez%
- :: (re)sharing DOTA_LAN
- net share DOTA_LAN /Y /delete 1>nul 2>nul
- net share DOTA_LAN="%dota_lan%" /remark:"Run dota_lan_update.bat" 1>nul 2>nul
- if exist "\\%COMPUTERNAME%\DOTA_LAN" (set rez=OK!) else set rez=FAIL!
- echo Creating share \\%COMPUTERNAME%\DOTA_LAN - %rez%
- :: done!
- call :end DONE!
- goto :eof
- :attachments [ Batch attachments ] export attachment file as is using writer function, instead of echoing every line to generate it
- :::dota_lan_update.bat:::
- @echo off & cd /d c:\ & setlocal disabledelayedexpansion & title AveYo's %~nx0 & color 0B & cls
- echo.
- echo -------------------------------------------------------------
- echo ^| AVEYO`S DOTA_LAN_UPDATE ^|
- echo ^|-------------------------------------------------------------^|
- echo ^| Directly run on PCs needing update from this LAN share ^|
- echo ^| Steam and DOTA should be set to disable automatic updates ^|
- echo ^| Script will not update non-essential and personal files ^|
- echo ^| ^|
- echo ^| Please wait for the script to finish, it will close itself ^|
- echo -------------------------------------------------------------
- echo.
- call :wait 5 Starting
- call :set_dota
- :::exp:::
- set "src=\\%computername%\DOTA_LAN"
- :::noexp:::
- set "dst=%steamapps%"
- set "xd=cfg guides replays screenshots"
- set "xf=*.mdmp *.soc *.vcfg condump*.txt console.log server_log.txt rich_presence*.txt"
- set "log=%UserProfile%\Desktop\dota_lan_update.log"
- set "dotacfg=common\dota 2 beta\game\dota\cfg"
- if exist "%src%" (set rez=OK!) else set rez=FAIL!
- echo Checking share %src% - %rez%
- if not exist "%src%" call :end # Cannot update, %src% not found
- robocopy "%src%\steamapps\%dotacfg%" "%dst%\%dotacfg%" user_keys_default.vcfg /Z 1>nul 2>nul
- robocopy "%src%\steamapps\common" "%dst%\common" /E /Z /J /SL /MT /XF %xf% /XD %xd% /XO /NS /NC /NP /NFL /NDL & rem /LOG:"%log%"
- echo Overwriting appmanifest_570.acf and restarting Steam
- taskkill /im steam.exe /t /f 1>nul 2>nul
- robocopy "%src%\steamapps" "%dst%" appmanifest_570.acf /Z 1>nul 2>nul
- set extra_options=-forceservice -nocrashmonitor -tcp -complete_install_via_http -single_core -no-dwrite -disable-winh264 -vrdisable
- start "w" "%steampath%\Steam.exe" -silent -console %extra_options%
- call :end DONE!
- endlocal & goto :eof
- :set_dota [ Batch shared functions ] - used by both main script and the dota_lan_update.bat attachment so no need to duplicate them
- rem set "steamapps=D:\STEAM LIBRARY\steamapps" & rem uncomment and adjust this line to override steamapps detection
- rem set "dota=D:\STEAM LIBRARY\steamapps\common\dota 2 beta\game" & rem uncomment and adjust this line to override dota detection
- set "steampath=c:\Program Files (x86)\Steam"
- rem goto :eof & rem uncomment to override steampath detection
- if not exist "%steampath%" call :get_reg "HKCU\SOFTWARE\Valve\Steam" "SteamPath" steampath
- if not exist "%steampath%" call :end # Cannot find SteamPath in registry HKCU\SOFTWARE\Valve\Steam!
- for %%s in ("%steampath%") do set "steampath=%%~dpns" & set "libfilter=LibraryFolders { TimeNextStatsReport ContentStatsID }"
- if not exist "%steampath%\SteamApps\libraryfolders.vdf" call :end # Cannot find Steam cfg %steampath%\SteamApps\libraryfolders.vdf!
- for /f usebackq^ delims^=^"^ tokens^=4 %%s in (`findstr /v "%libfilter%" "%steampath%\SteamApps\libraryfolders.vdf"`) do (
- if exist "%%s\steamapps\appmanifest_570.acf" if exist "%%s\steamapps\common\dota 2 beta\game\dota\maps\dota.vpk" set "libfs=%%s")
- set "steamapps=%steampath%\steamapps"
- if defined libfs set "steamapps=%libfs:\\=\%\steamapps"
- if not exist "%steamapps%\common\dota 2 beta\game\dota\maps\dota.vpk" call :end # Cannot find DOTA - %steamapps%\common\dota 2 beta!
- set "dota=%steamapps%\common\dota 2 beta\game" & goto :eof
- :get_reg Params: 1=KeyName 2=ValueName 3=TargetVariable
- for /f "usebackq delims=? eol=*" %%s in (`reg query "%~1" /v "%~2"`) do set "_r_=%%s" & call set "_r_=%%_r_: =?%%"
- for /f "delims=? tokens=3* eol=*" %%s in ("%_r_%") do call set "%~3=%%s" & set "_r_=" & goto :eof
- :wait Params: 1=Seconds 2=Message
- setlocal enabledelayedexpansion &if not defined x1337cr for /f %%a in ('copy /z "%~dpf0" nul') do set "x1337cr=%%a"
- (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
- :end Params: 1=Message - start with # to signal error
- (if "%1"=="#" COLOR 7c) &echo. &echo %* &(call :wait 9 Closing) &echo/ &(if "%1"=="#" exit) &endlocal &color &goto :eof
- :::eof:::
- :init [ Batch main functions ]
- @echo off & setlocal disabledelayedexpansion &title AveYo's %~nx0 &color 0B &cls & if "%1"=="_SELF_ADMIN" shift &shift & goto :start
- reg query "HKEY_USERS\S-1-5-20\Environment" /v temp 1>nul 2>nul && goto :start || echo Requesting admin rights.. & color 7c
- call cscript /nologo /e:JScript "%~f0" get_rights "%1" & exit & goto :eof
- :writer Params: 1=Filename - exports content from :::Filename::: to :::eof::: - expands variables from :::exp::: to :::noexp::: line
- <nul set /p "=">%1 & set "_w=" & set "_e=" & for /f "tokens=1* delims=]" %%r in ('call find.exe /v /n "" "%~f0"') do (
- (if "%%s"==":::%~1:::" set _w=)&(if "%%s"==":::eof:::" set _w=)&(if "%%s"==":::exp:::" set _e=1)&(if "%%s"==":::noexp:::" set _e=)
- if defined _w (if defined _e (call echo/%%s>>%1) else echo/%%s>>%1) else if "%%s"==":::%~1:::" set _w=1)
- goto :eof
- *//* [ JScript functions ] all lines above are ignored by starting script with a js comment */
- function get_rights(fn) {WSH.CreateObject("Shell.Application").ShellExecute(fn,"_SELF_ADMIN "+fn+" "+WSH.Arguments(1),"","runas",1)}
- if (WSH.Arguments.length>=1) {if (WSH.Arguments(0)=="get_rights") get_rights(WSH.ScriptFullName)}
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement