@echo off
setlocal enabledelayedexpansion
rem 從註冊表尋找 League of Legends.exe 安裝路徑
for /f "tokens=3* delims= " %%a in ('REG query "HKEY_CURRENT_USER\Software\Microsoft\IntelliPoint\AppSpecific\League of Legends.exe" /v "Path"') do (set r1=%%a %%b)
for /f "tokens=1-4 delims=\" %%a in ('echo %r1%') do (
set r1=%%a\%%b\%%c\%%d
set LOL_PATH=%%a\%%b\%%c\)
rem 提取版本號碼
for /f "delims=" %%b in ('type "%r1%\compat-version-metadata.json" ^|find "version"') do set "content=%%b"
rem 去除空格
set content=%content: =%
echo 當前觀戰程式版本:%content:~11,8%
echo.
dir "%~dp0\*.rofl" /B >nul
if %ERRORLEVEL% EQU 1 (
echo %~dp0
echo 資料夾內無觀戰紀錄檔 rofl
echo.
echo 按任意鍵離開
PAUSE>nul
exit /B
)
rem 取得該資料夾最後修改日期的rofl
for /f "delims=" %%a in ('powershell.exe -Command "Get-ChildItem -Path *.rofl | Sort-Object LastWriteTime -Descending | Select-Object -First 1 -Property FullName"') do set "new_rofl=%%a"
echo rofl 檔案位置:%new_rofl%
powershell.exe -Command "(Get-Content -Path '%new_rofl%' -Raw | Out-String -Stream | ForEach-Object { $_ -replace '[^\x20-\x7E]', '' } | ForEach-Object { if ($_ -match '(..?)\.(.*?)\.(.*?)\.(.{4})') { \"rofl 版本 :$($matches[1]).$($matches[2]).$($matches[3]).$($matches[4])\" } })"
echo.
ping 127.0.0.1 -n 1 >nul
rem 檢查rofl版本
find "%content:~11,8%" "%new_rofl%">nul
if %errorlevel% EQU 0 (echo 版本正確) else if %errorlevel% EQU 1 (
echo replay rofl 版本錯誤,結束觀看Replay
echo.
echo 按任意鍵離開 & PAUSE>nul
exit /B
)
rem 取得設定檔內的地區並前往執行
:runSpectate
for /f "tokens=* delims= " %%a in ("%LOL_PATH%") do set LOL_PATH=%%a
for /l %%a in (1,1,100) do if "!LOL_PATH:~-1!"==" " set LOL_PATH=!LOL_PATH:~0,-1!
cd /D %LOL_PATH%
for /f "tokens=1,* delims=" %%i in ('type Config\LeagueClientSettings.yaml ^| find /i "locale:"') do (
set line=%%i
call :Trim trimmed !line!
SET locale=!trimmed:~9,-1!
)
cd Game
rem 最後確認,並前往"開始"
if exist "League of Legends.exe" (
goto start
)
rem 如果找不到英雄聯盟,則前往"未找到"
goto notfound
rem 開始執行觀看程式
:start
TASKKILL /IM vgtray.exe>nul 2>nul
sc stop "vgc">nul 2>nul
sc stop "vgk">nul 2>nul
for /f "tokens=1*" %%a in ('dir "%~dp0\*.rofl" /O:D /B') do set b1=%%a
@start "" "League of Legends.exe" "%~dp0/%b1%" "-GameBaseDir=.." "-Region=TW2" "-PlatformID=TW2" "-Locale=zh_TW" "-SkipBuild" "-EnableCrashpad=true" "-EnableLNP" "-UseDX11=1:1" "-UseMetal=0:1" "-UseNewX3D" "-UseNewX3DFramebuffers"
ping 127.0.0.1 -n 5 >nul
sc start "vgc">nul 2>nul
start "" "C:\Program Files\Riot Vanguard\vgtray.exe" /B
goto exit
:Trim
SetLocal EnableDelayedExpansion
set Params=%*
for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b
exit /b
rem 找不到英雄聯盟
:notfound
cls
echo 找不到您的英雄聯盟安裝路徑。
set /p manualFolder="請手動輸入您的英雄聯盟安裝路徑:"
call :Trim manualFolder !manualFolder!
IF "!manualFolder!" NEQ "" (
echo !manualFolder! > "%APPDATA%\LoG_lolinstallpath.txt"
)
goto start
:exit
1.只能有一個rofl
2.非當前版本檔案無法觀看
3.rofl和bat要放在同一個資料夾
%userprofile%\Documents\League of Legends\Replays
202408 測試發現 Vanguar 會擋住觀戰程式 League of Legends.exe 的讀取權限
(警告!請勿在關閉 Vanguar 的情況下遊玩 LOL,後果自負!)
======================
202409 新增防呆,僅會抓最後一個更新日期的.rofl
======================
202411 已添加指令在觀戰啟動時關閉 Vanguar,並在觀戰程式開啟後五秒開啟 Vanguar
沒有留言:
張貼留言