@echo off
REM ----------------------------------------------
echo Deleting firewall rules (old names).
netsh advfirewall firewall delete rule name=NxRelay_53_in > NUL
netsh advfirewall firewall delete rule name=NxRelay_19002_in > NUL
REM -
REM ----------------------------------------------
echo Deleting firewall rules (new names).
netsh advfirewall firewall delete rule name=NxRelay_UDP_53_in > NUL
netsh advfirewall firewall delete rule name=NxRelay_TCP_19002_in > NUL
REM -
REM ----------------------------------------------
echo Adding firewall rules (new names).
netsh advfirewall firewall add rule name=NxRelay_UDP_53_in protocol=UDP dir=in localport=53 action=allow > NUL
netsh advfirewall firewall add rule name=NxRelay_TCP_19002_in protocol=TCP dir=in localport=19002 action=allow > NUL
REM -
REM ----------------------------------------------
set BPATH=%~dp0
cd %BPATH%
REM -
if not exist ..\conf\appname (
  echo [ERROR] No appname file.
  exit /b 1
)
set /p APPNAME=<..\conf\appname
REM -
REM ----------------------------------------------
"%BPATH%nssm.exe" install %APPNAME% "%BPATH%\startup.bat"
"%BPATH%nssm.exe" set %APPNAME% Start SERVICE_AUTO_START
