@echo off
chcp 936
echo  =============================================================== 
echo                        直播管理系统
echo                             安装 
echo  =============================================================== 
color 0A
sc query liveserver | findstr liveserver >nul 2>nul
if not errorlevel 1 (goto exist) else goto notexist
:exist
echo 服务已经存在,按任意键退出...
pause
exit
:notexist
echo "正在安装服务,请等待..."
for %%i in ("%~dp0..") do set "PDIR=%%~fi"
%PDIR%\work\liveserver.exe install.js %PDIR%\work %PDIR%\work\liveserver.exe main.js %CD%
server.exe install
echo 服务安装成功,请在服务管理控制台手工启动 liveserver 或 按 's' 键直接启动 
set /p UserChoice=
if "%UserChoice%"=="s" goto startup
exit
:startup
net start liveserver >nul 2>nul
if errorlevel 1 (
	echo 由于授权问题,服务启动失败，请在控制台手工启动	
	pause
	exit
)
echo 服务启动成功
pause	



