@echo off
cd /d "%~dp0"
cd ..

set nssm_exe=bin\nssm.exe
set service_name=Converter

set uninstall_service_output=log\uninstall_service.log
if exist %uninstall_service_output% ( del %uninstall_service_output% /f )

echo [32m[uninstall_service INFO] Remove "Converter" service.[0m
echo [uninstall_service INFO] Remove "Converter" service. >> %uninstall_service_output%
%nssm_exe% stop %service_name% >> %uninstall_service_output%

%nssm_exe% remove %service_name% confirm
set error_code=%errorlevel%
if %error_code% equ 3 (
	echo [33m[uninstall_service WARN] Can not find the corresponding path. The "Converter" service may not be installed.[0m
	echo [uninstall_service WARN] Can not find the corresponding path. The "Converter" service may not be installed. >> %uninstall_service_output%
	goto Fail
) else if %error_code% gtr 0 (
	echo [31m[uninstall_service ERROR] Error code %error_code%.[0m
	echo [uninstall_service ERROR] Error code %error_code%. >> %uninstall_service_output%
	goto Fail
)
goto End

:Fail
goto End

:End

