fix(installer/windows): remember service start type (#3902)

This commit is contained in:
ReenigneArcher
2025-05-24 19:40:07 -04:00
committed by GitHub
parent ef5253a61d
commit 3ad90cd7f1
2 changed files with 64 additions and 1 deletions

View File

@@ -1,4 +1,36 @@
@echo off
setlocal enabledelayedexpansion
set "SERVICE_CONFIG_DIR=%LOCALAPPDATA%\LizardByte\Sunshine"
set "SERVICE_CONFIG_FILE=%SERVICE_CONFIG_DIR%\service_start_type.txt"
rem Save the current service start type to a file if the service exists
sc qc SunshineService >nul 2>&1
if %ERRORLEVEL%==0 (
if not exist "%SERVICE_CONFIG_DIR%\" mkdir "%SERVICE_CONFIG_DIR%\"
rem Get the start type
for /f "tokens=3" %%i in ('sc qc SunshineService ^| findstr /C:"START_TYPE"') do (
set "CURRENT_START_TYPE=%%i"
)
rem Set the content to write
if "!CURRENT_START_TYPE!"=="2" (
sc qc SunshineService | findstr /C:"(DELAYED)" >nul
if !ERRORLEVEL!==0 (
set "CONTENT=2-delayed"
) else (
set "CONTENT=2"
)
) else if "!CURRENT_START_TYPE!" NEQ "" (
set "CONTENT=!CURRENT_START_TYPE!"
) else (
set "CONTENT=unknown"
)
rem Write content to file
echo !CONTENT!> "%SERVICE_CONFIG_FILE%"
)
rem Stop and delete the legacy SunshineSvc service
net stop sunshinesvc