mirror of
https://github.com/SillyTavern/SillyTavern-Launcher.git
synced 2026-01-26 17:09:44 +00:00
launcher improvements
Fixes issue: #34 + changed how PATH is getting saved in the registry to avoid emty strings for winget, 7-zip and ffmpeg
This commit is contained in:
109
Launcher.bat
109
Launcher.bat
@@ -88,6 +88,37 @@ REM Load module flags from modules-xtts.txt
|
||||
for /f "tokens=*" %%a in (modules-xtts.txt) do set "%%a"
|
||||
|
||||
|
||||
|
||||
REM Get the current PATH value from the registry
|
||||
for /f "tokens=2*" %%A in ('reg query "HKCU\Environment" /v PATH') do set "current_path=%%B"
|
||||
|
||||
REM Check if the paths are already in the current PATH
|
||||
echo %current_path% | find /i "%winget_path%" > nul
|
||||
set "ff_path_exists=%errorlevel%"
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Append the new paths to the current PATH only if they don't exist
|
||||
if %ff_path_exists% neq 0 (
|
||||
set "new_path=%current_path%;%winget_path%"
|
||||
echo.
|
||||
echo [DEBUG] "current_path is:%cyan_fg_strong% %current_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "winget_path is:%cyan_fg_strong% %winget_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "new_path is:%cyan_fg_strong% !new_path!%reset%"
|
||||
|
||||
REM Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "!new_path!" /f
|
||||
|
||||
REM Update the PATH value for the current session
|
||||
setx PATH "!new_path!" > nul
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%winget added to PATH.%reset%
|
||||
) else (
|
||||
set "new_path=%current_path%"
|
||||
echo %blue_fg_strong%[INFO] winget already exists in PATH.%reset%
|
||||
)
|
||||
|
||||
REM Check if Winget is installed; if not, then install it
|
||||
winget --version > nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
@@ -95,34 +126,13 @@ if %errorlevel% neq 0 (
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Installing Winget...
|
||||
curl -L -o "%temp%\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" "https://github.com/microsoft/winget-cli/releases/download/v1.6.2771/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
|
||||
start "" "%temp%\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%Winget installed successfully.%reset%
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%Winget installed successfully. Please restart the Launcher.%reset%
|
||||
pause
|
||||
exit
|
||||
) else (
|
||||
echo %blue_fg_strong%[INFO] Winget is already installed.%reset%
|
||||
)
|
||||
|
||||
rem Get the current PATH value from the registry
|
||||
for /f "tokens=2*" %%A in ('reg query "HKCU\Environment" /v PATH') do set "current_path=%%B"
|
||||
|
||||
rem Check if the paths are already in the current PATH
|
||||
echo %current_path% | find /i "%winget_path%" > nul
|
||||
set "ff_path_exists=%errorlevel%"
|
||||
|
||||
rem Append the new paths to the current PATH only if they don't exist
|
||||
if %ff_path_exists% neq 0 (
|
||||
set "new_path=%current_path%;%winget_path%"
|
||||
|
||||
rem Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "%new_path%" /f
|
||||
|
||||
rem Update the PATH value for the current session
|
||||
setx PATH "%new_path%" > nul
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%winget added to PATH.%reset%
|
||||
) else (
|
||||
set "new_path=%current_path%"
|
||||
echo %blue_fg_strong%[INFO] winget already exists in PATH.%reset%
|
||||
)
|
||||
|
||||
|
||||
REM Check if Git is installed if not then install git
|
||||
git --version > nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
@@ -700,21 +710,29 @@ rem Check if the paths are already in the current PATH
|
||||
echo %current_path% | find /i "%zip7_install_path%" > nul
|
||||
set "zip7_path_exists=%errorlevel%"
|
||||
|
||||
rem Append the new paths to the current PATH only if they don't exist
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Append the new paths to the current PATH only if they don't exist
|
||||
if %zip7_path_exists% neq 0 (
|
||||
set "new_path=%current_path%;%zip7_install_path%"
|
||||
echo %green_fg_strong%7-Zip added to PATH.%reset%
|
||||
echo.
|
||||
echo [DEBUG] "current_path is:%cyan_fg_strong% %current_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "zip7_install_path is:%cyan_fg_strong% %zip7_install_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "new_path is:%cyan_fg_strong% !new_path!%reset%"
|
||||
|
||||
REM Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "!new_path!" /f
|
||||
|
||||
REM Update the PATH value for the current session
|
||||
setx PATH "!new_path!" > nul
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%7-zip added to PATH.%reset%
|
||||
) else (
|
||||
set "new_path=%current_path%"
|
||||
echo %blue_fg_strong%[INFO] 7-Zip already exists in PATH.%reset%
|
||||
)
|
||||
|
||||
rem Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "%new_path%" /f
|
||||
|
||||
rem Update the PATH value for the current session
|
||||
setx PATH "%new_path%"
|
||||
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%7-Zip installed successfully. Please restart the Launcher.%reset%
|
||||
pause
|
||||
exit
|
||||
@@ -759,23 +777,30 @@ rem Check if the paths are already in the current PATH
|
||||
echo %current_path% | find /i "%bin_path%" > nul
|
||||
set "ff_path_exists=%errorlevel%"
|
||||
|
||||
rem Append the new paths to the current PATH only if they don't exist
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Append the new paths to the current PATH only if they don't exist
|
||||
if %ff_path_exists% neq 0 (
|
||||
set "new_path=%current_path%;%bin_path%"
|
||||
echo %green_fg_strong%ffmpeg added to PATH.%reset%
|
||||
echo.
|
||||
echo [DEBUG] "current_path is:%cyan_fg_strong% %current_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "bin_path is:%cyan_fg_strong% %bin_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "new_path is:%cyan_fg_strong% !new_path!%reset%"
|
||||
|
||||
REM Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "!new_path!" /f
|
||||
|
||||
REM Update the PATH value for the current session
|
||||
setx PATH "!new_path!" > nul
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%ffmpeg added to PATH.%reset%
|
||||
) else (
|
||||
set "new_path=%current_path%"
|
||||
echo %blue_fg_strong%[INFO] ffmpeg already exists in PATH.%reset%
|
||||
)
|
||||
|
||||
rem Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "%new_path%" /f
|
||||
|
||||
rem Update the PATH value for the current session
|
||||
setx PATH "%new_path%" > nul
|
||||
|
||||
del "%ffdownload_path%"
|
||||
echo %green_fg_strong%FFmpeg is installed. Please restart the Launcher.%reset%
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%ffmpeg installed successfully. Please restart the Launcher.%reset%
|
||||
pause
|
||||
exit
|
||||
|
||||
|
||||
@@ -45,6 +45,36 @@ set "startIn=%~dp0"
|
||||
set "comment=SillyTavern Launcher"
|
||||
|
||||
|
||||
REM Get the current PATH value from the registry
|
||||
for /f "tokens=2*" %%A in ('reg query "HKCU\Environment" /v PATH') do set "current_path=%%B"
|
||||
|
||||
REM Check if the paths are already in the current PATH
|
||||
echo %current_path% | find /i "%winget_path%" > nul
|
||||
set "ff_path_exists=%errorlevel%"
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM Append the new paths to the current PATH only if they don't exist
|
||||
if %ff_path_exists% neq 0 (
|
||||
set "new_path=%current_path%;%winget_path%"
|
||||
echo.
|
||||
echo [DEBUG] "current_path is:%cyan_fg_strong% %current_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "winget_path is:%cyan_fg_strong% %winget_path%%reset%"
|
||||
echo.
|
||||
echo [DEBUG] "new_path is:%cyan_fg_strong% !new_path!%reset%"
|
||||
|
||||
REM Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "!new_path!" /f
|
||||
|
||||
REM Update the PATH value for the current session
|
||||
setx PATH "!new_path!" > nul
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%winget added to PATH.%reset%
|
||||
) else (
|
||||
set "new_path=%current_path%"
|
||||
echo %blue_fg_strong%[INFO] winget already exists in PATH.%reset%
|
||||
)
|
||||
|
||||
REM Check if Winget is installed; if not, then install it
|
||||
winget --version > nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
@@ -52,34 +82,13 @@ if %errorlevel% neq 0 (
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% Installing Winget...
|
||||
curl -L -o "%temp%\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" "https://github.com/microsoft/winget-cli/releases/download/v1.6.2771/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
|
||||
start "" "%temp%\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%Winget installed successfully.%reset%
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%Winget installed successfully. Please restart the Launcher.%reset%
|
||||
pause
|
||||
exit
|
||||
) else (
|
||||
echo %blue_fg_strong%[INFO] Winget is already installed.%reset%
|
||||
)
|
||||
|
||||
|
||||
rem Get the current PATH value from the registry
|
||||
for /f "tokens=2*" %%A in ('reg query "HKCU\Environment" /v PATH') do set "current_path=%%B"
|
||||
|
||||
rem Check if the paths are already in the current PATH
|
||||
echo %current_path% | find /i "%winget_path%" > nul
|
||||
set "ff_path_exists=%errorlevel%"
|
||||
|
||||
rem Append the new paths to the current PATH only if they don't exist
|
||||
if %ff_path_exists% neq 0 (
|
||||
set "new_path=%current_path%;%winget_path%"
|
||||
|
||||
rem Update the PATH value in the registry
|
||||
reg add "HKCU\Environment" /v PATH /t REG_EXPAND_SZ /d "%new_path%" /f
|
||||
|
||||
rem Update the PATH value for the current session
|
||||
setx PATH "%new_path%" > nul
|
||||
echo %blue_bg%[%time%]%reset% %blue_fg_strong%[INFO]%reset% %green_fg_strong%winget added to PATH.%reset%
|
||||
) else (
|
||||
set "new_path=%current_path%"
|
||||
echo %blue_fg_strong%[INFO] winget already exists in PATH.%reset%
|
||||
)
|
||||
|
||||
endlocal
|
||||
|
||||
REM Check if Git is installed if not then install git
|
||||
git --version > nul 2>&1
|
||||
|
||||
Reference in New Issue
Block a user