Skip to content

Commit

Permalink
Update v1.0.4
Browse files Browse the repository at this point in the history
Adding Update check and auto update feature.
  • Loading branch information
FLYEMOJ1 committed Nov 23, 2023
1 parent 33d98d5 commit a44ebd6
Showing 1 changed file with 94 additions and 40 deletions.
134 changes: 94 additions & 40 deletions RiotClientLanguageSelector.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,75 +12,127 @@
:: 本工具使用了 MIT License
::
:: 如果您花钱购买了该工具,那证明你已经被骗钱了。这是个免费软件。
::
::
:: Last Update: KST 2023-11-22 9:40 PM
:: Update log: Add a taskkill set to Force LeagueClient off.

@echo off
setlocal enabledelayedexpansion
set version=v1.0.4
set GITHUB_REPO=FLYEMOJ1/RiotClient-League-LanguageSelector-Windows
set REPO_NAME=RiotClient-League-LanguageSelector-Windows
set TEMP_DIR=%TEMP%\RiotClientLanguageSelector_update_temp
set "INSTALL_DIR=%~p0"

:: getAdmin
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
:: If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
) else (
goto getAdmin
)

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B

:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:getAdmin
pushd "%CD%"
CD /D "%~dp0"

echo Running with administrative privileges. To make sure this will work.
echo Checking Updates.

:: Force remove temp files. and create temp directory.
rd /s /q "%TEMP_DIR%"
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"

cd "%TEMP_DIR%"

:: Get latest version.
curl -s "https://api.github.com/repos/%GITHUB_REPO%/releases/latest" > latest_release.json

:: Resolve JSON and get version code
for /f "tokens=2 delims=:, " %%I in ('type latest_release.json ^| find /i "tag_name"') do set REMOTE_VERSION=%%~I

if "%REMOTE_VERSION%"=="" (
echo Cannot get latest version. Please Check GitHub Releases API is available?
goto :preload
)

:: Compare local and remote version. If local version is newer or equal, then skip update.
if "%version%" geq "%REMOTE_VERSION%" (
echo You have the Latest Version of leagueClient Language Selector.
goto :preload
)

echo Latest version is: %REMOTE_VERSION%

echo Downloading latest version...

:: Download latest version. (from GitHub and ZIP)
curl -L "https://codeload.github.com/FLYEMOJ1/RiotClient-League-LanguageSelector-Windows/zip/refs/heads/main" -o update.zip

:: Decompress to temp.
powershell Expand-Archive -Path update.zip -DestinationPath .

:: Copy update file to installation location.
xcopy /y "%TEMP_DIR%\%REPO_NAME%-main\RiotClientLanguageSelector.bat" "%INSTALL_DIR%"

echo Update Complete.
start "" "%INSTALL_DIR%\RiotClientLanguageSelector.bat"
goto end

:update_Cleanup
:: Remove temp files.
del /q update.zip
cd ..
rd /s /q "%TEMP_DIR%"

:preload
:: Force Riot Client Off.
title PreLoading...
cls
title PreLoading... 0%
echo Killing Riot Game Clients.
taskkill /t /f /im LeagueClient.exe
taskkill /t /f /im LeagueClient.exe >nul 2>&1
title PreLoading... 10%
taskkill /t /f /im LeagueClientUx.exe
taskkill /t /f /im LeagueClientUxRender.exe
echo PreLoading... 10%
taskkill /t /f /im LeagueClientUx.exe >nul 2>&1
taskkill /t /f /im LeagueClientUxRender.exe >nul 2>&1
title PreLoading... 30%
taskkill /t /f /im LeagueCrashHandler64.exe
taskkill /t /f /im RiotClientCrashHandler.exe
taskkill /t /f /im RiotClientServices.exe
echo PreLoading... 30%
taskkill /t /f /im LeagueCrashHandler64.exe >nul 2>&1
taskkill /t /f /im RiotClientCrashHandler.exe >nul 2>&1
taskkill /t /f /im RiotClientServices.exe >nul 2>&1
title PreLoading... 60%
taskkill /t /f /im RiotClientUx.exe
taskkill /t /f /im RiotClientUxRender.exe
echo PreLoading... 60%
taskkill /t /f /im RiotClientUx.exe >nul 2>&1
taskkill /t /f /im RiotClientUxRender.exe >nul 2>&1
title PreLoading... 80%
taskkill /t /f /im VALORANT.exe
echo PreLoading... 80%
taskkill /t /f /im VALORANT.exe >nul 2>&1
title PreLoading... 100%
echo PreLoading... 100%
cls
:: End of Shit hole.

:: Start of Title set.
echo If stuck at here, Please press enter.
:: End of cleanup.

title League of Legends Language Selector

:: End of Title set.
title League of Legends Language Selector %version%

:: Set Where leagueClient info file is gonna save.
set "leagueClient_info_file=%userprofile%\leagueClient_info.txt"

:: Check leagueClient_Info.txt exist. If not, then let user manualy input.
:: Check if leagueClient_Info.txt exists. If not, then let the user manually input the leagueClient directory.
if not exist "%leagueClient_info_file%" (
echo Please manual input leagueClient directory *no exe only directory*
echo Please manually input the leagueClient directory. no exe, only directory.
set /p "leagueClient_path="
echo !leagueClient_path!> "%leagueClient_info_file%"
) else (
:: From Saved file to read leagueClient Directory.
:: Read leagueClient directory from the saved file.
set /p leagueClient_path=<"%leagueClient_info_file%"
)

Expand All @@ -90,12 +142,13 @@ cls
echo Select Language:
echo 1. English
echo 2. Chinese Simplified
echo 3. Chinese Tradionnal
echo 3. Chinese Traditional
echo 4. Japanese
echo 5. Korean
echo 6. WTF Where am I just let me leave
echo 6. Exit

set /p "language_choice="

if "%language_choice%"=="1" (
set "language=en_US"
) else if "%language_choice%"=="2" (
Expand All @@ -109,12 +162,13 @@ if "%language_choice%"=="1" (
) else if "%language_choice%"=="6" (
exit
) else (
echo JUST INPUT NUMBER !!!
echo JUST INPUT A NUMBER !!!
pause
goto :language_menu
)

:: Start LeagueClient.exe with selected language.
:: Start LeagueClient.exe with the selected language.
echo
start "" "%leagueClient_path%\LeagueClient.exe" "--locale=!language!"

:end
:end

0 comments on commit a44ebd6

Please sign in to comment.