56 lines
1.3 KiB
Batchfile
56 lines
1.3 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions
|
|
|
|
set "SERVICE_NAME=LuxtoolsClient"
|
|
set "INSTALL_DIR=%ProgramFiles%\LuxtoolsClient"
|
|
set "DATA_DIR=%ProgramData%\LuxtoolsClient"
|
|
|
|
rem Optional args:
|
|
rem --keep-config
|
|
|
|
set "KEEP_CONFIG=0"
|
|
if /I "%~1"=="-h" goto :usage
|
|
if /I "%~1"=="--help" goto :usage
|
|
if /I "%~1"=="--keep-config" set "KEEP_CONFIG=1"
|
|
|
|
goto :main
|
|
|
|
:usage
|
|
echo Usage: %~nx0 [--keep-config]
|
|
echo.
|
|
echo Uninstalls luxtools-client Windows Service and removes installed files.
|
|
echo.
|
|
echo Options:
|
|
echo --keep-config Keeps %DATA_DIR% (token/config).
|
|
exit /b 2
|
|
|
|
:main
|
|
net session >nul 2>&1
|
|
if not "%ERRORLEVEL%"=="0" (
|
|
echo This script must be run as Administrator.
|
|
exit /b 1
|
|
)
|
|
|
|
sc.exe query "%SERVICE_NAME%" >nul 2>&1
|
|
if "%ERRORLEVEL%"=="0" (
|
|
sc.exe stop "%SERVICE_NAME%" >nul 2>&1
|
|
rem Wait up to ~20s for the service to fully stop.
|
|
for /L %%i in (1,1,20) do (
|
|
sc.exe query "%SERVICE_NAME%" | findstr /I "STATE" | findstr /I "STOPPED" >nul 2>&1
|
|
if "%ERRORLEVEL%"=="0" goto :stopped
|
|
timeout /T 1 /NOBREAK >nul
|
|
)
|
|
:stopped
|
|
sc.exe delete "%SERVICE_NAME%" >nul 2>&1
|
|
)
|
|
|
|
if exist "%INSTALL_DIR%" rmdir /S /Q "%INSTALL_DIR%" >nul 2>&1
|
|
if "%KEEP_CONFIG%"=="0" (
|
|
if exist "%DATA_DIR%" rmdir /S /Q "%DATA_DIR%" >nul 2>&1
|
|
)
|
|
|
|
echo Uninstalled luxtools-client.
|
|
if "%KEEP_CONFIG%"=="1" echo Kept config directory: %DATA_DIR%
|
|
endlocal
|
|
exit /b 0
|