2021-07-18 22:24:55 +00:00
|
|
|
@echo off
|
|
|
|
|
2022-08-15 00:53:38 +00:00
|
|
|
rem Get sunshine root directory
|
|
|
|
for %%I in ("%~dp0\..") do set "root_dir=%%~fI"
|
|
|
|
|
2021-07-18 22:24:55 +00:00
|
|
|
set SERVICE_NAME=sunshinesvc
|
2022-08-15 00:53:38 +00:00
|
|
|
set SERVICE_BIN="%root_dir%\tools\sunshinesvc.exe"
|
2021-07-18 22:24:55 +00:00
|
|
|
set SERVICE_START_TYPE=auto
|
|
|
|
|
|
|
|
rem Check if sunshinesvc already exists
|
|
|
|
sc qc %SERVICE_NAME% > nul 2>&1
|
|
|
|
if %ERRORLEVEL%==0 (
|
|
|
|
rem Stop the existing service if running
|
|
|
|
net stop %SERVICE_NAME%
|
|
|
|
|
|
|
|
rem Reconfigure the existing service
|
|
|
|
set SC_CMD=config
|
|
|
|
) else (
|
|
|
|
rem Create a new service
|
|
|
|
set SC_CMD=create
|
|
|
|
)
|
|
|
|
|
|
|
|
rem Run the sc command to create/reconfigure the service
|
|
|
|
sc %SC_CMD% %SERVICE_NAME% binPath= %SERVICE_BIN% start= %SERVICE_START_TYPE%
|
|
|
|
|
|
|
|
rem Start the new service
|
|
|
|
net start %SERVICE_NAME%
|