1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | @echo off setlocal enabledelayedexpansion 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" rem 提取版本號碼 for /f "delims=" %%b in ('type "C:\Riot Games\League of Legends\Game\compat-version-metadata.json" ^|find "version"') do set "content=%%b" rem 去除空格 set content=%content: =% echo 當前觀戰程式版本:%content:~11,8% echo. dir %~dp0\*.rofl /B 2>nul if %ERRORLEVEL% EQU 1 (echo %~dp0 & echo 資料夾內無觀戰紀錄檔 rofl & echo. & echo 按任意鍵離開 & PAUSE>nul &exit /B) echo %new_rofl% rem 檢查rofl版本 for /f "delims=" %%c in ('type "%new_rofl%" ^|find "gameVersion"') do set "test=%%c" type "%new_rofl%" |find "gameVersion">%~dp0\gameVersion.txt for /f "tokens=2 delims=," %%d in ('type %~dp0\gameVersion.txt') do set "gameVersion=%%d" echo rofl版本:%gameVersion% del %~dp0\gameVersion.txt /Q echo. 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 ) :start rem 開始 rem 如果LoG_lolinstallpath.txt檔案不存在,取得正在執行中LeagueClient.exe的PID set LOL_PATH="" if exist "%APPDATA%\LoG_lolinstallpath.txt" ( set /p LOL_PATH0=< "%APPDATA%\LoG_lolinstallpath.txt" call :Trim LOL_PATH !LOL_PATH0! echo Manually set Path found: "!LOL_PATH!" IF EXIST "!LOL_PATH!" ( goto runSpectate ) ) rem 取得正在執行中LeagueClient.exe的PID for /F "delims=" %%R in (' tasklist /FI "ImageName eq LeagueClient.exe" /FI "Status eq Running" /FO CSV /NH ') do ( set "FLAG1=" & set "FLAG2=" for %%C in (%%R) do ( if defined FLAG1 ( if not defined FLAG2 ( set LOL_PID=%%~C IF NOT "%LOL_PID%"=="" goto pidFound ) set "FLAG2=#" ) set "FLAG1=#" ) ) rem 通過讀取註冊表中Riot_Games的值尋找安裝路徑 FOR %%G IN ("HKLM\SOFTWARE\WOW6432Node\Riot Games, Inc\League of Legends") DO ( for /f "usebackq skip=2 tokens=1,2*" %%a in (`%systemroot%\system32\REG.EXE QUERY %%G /v "Location"`) do ( set LOL_PATH=%%c echo "Path found: !LOL_PATH! goto runSpectate ) ) rem 如果上述方法都不成功,則使用下面猜猜樂大法 IF EXIST "C:\Riot Games\League of Legends" ( set LOL_PATH="C:\Riot Games\League of Legends" goto runSpectate ) IF EXIST "D:\Riot Games\League of Legends" ( set LOL_PATH="D:\Riot Games\League of Legends" goto runSpectate ) IF EXIST "C:\Program Files\Riot Games\League of Legends" ( set LOL_PATH="C:\Program Files\Riot Games\League of Legends" goto runSpectate ) IF EXIST "C:\Program Files (x86)\Riot Games\League of Legends" ( set LOL_PATH="C:\Program Files (x86)\Riot Games\League of Legends" goto runSpectate ) IF EXIST "C:\Program Files\League of Legends" ( set LOL_PATH="C:\Program Files\League of Legends" goto runSpectate ) IF EXIST "C:\Program Files (x86)\League of Legends" ( set LOL_PATH="C:\Program Files (x86)\League of Legends" goto runSpectate ) IF EXIST "D:\Program Files\Riot Games\League of Legends" ( set LOL_PATH="D:\Program Files\Riot Games\League of Legends" goto runSpectate ) IF EXIST "D:\Program Files (x86)\Riot Games\League of Legends" ( set LOL_PATH="D:\Program Files (x86)\Riot Games\League of Legends" goto runSpectate ) IF EXIST "D:\Program Files\League of Legends" ( set LOL_PATH="D:\Program Files\League of Legends" goto runSpectate ) IF EXIST "D:\Program Files (x86)\League of Legends" ( set LOL_PATH="D:\Program Files (x86)\League of Legends" goto runSpectate ) goto notfound :pidFound set "lcpath=" for /f "skip=1delims=" %%a in ( 'wmic process where "ProcessID=%LOL_PID%" get ExecutablePath' ) do if not defined lcpath set "lcpath=%%a" For %%A in ("%lcpath%") do ( Set LOL_PATH=%%~dpA ) goto runSpectate rem 取得設定檔內的地區並前往執行 :runSpectate cls 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 :start for /f "tokens=1*" %%a in ('dir %~dp0\*.rofl /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" goto exit rem 如果找不到英雄聯盟,則前往"未找到" :Trim SetLocal EnableDelayedExpansion set Params=%* for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b exit /b :notfound cls echo 找不到您的英雄聯盟安裝路徑。 set /p manualFolder="請手動輸入您的英雄聯盟安裝路徑:" call :Trim manualFolder !manualFolder! IF "!manualFolder!" NEQ "" ( echo !manualFolder! > "%APPDATA%\LoG_lolinstallpath.txt" ) goto start :exit |
Direct link: https://paste.plurk.com/show/BtL9ZDTC20jtdg4JKLRE