@echo off
REM ##############################################
echo Deleting firewall rules (old names).
netsh advfirewall firewall delete rule name=NxFilter_53_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_80_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_443_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_19002_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_19003_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_19004_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP19004_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_19003_out > NUL
netsh advfirewall firewall delete rule name=NxFilter_19004_out > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP19004_out > NUL
netsh advfirewall firewall delete rule name=NxFilter_1813_in > NUL
REM ##############################################
echo Deleting firewall rules (new names).
netsh advfirewall firewall delete rule name=NxFilter_UDP_53_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_80_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_443_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_19002_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_19003_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_19004_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_19003_out > NUL
netsh advfirewall firewall delete rule name=NxFilter_TCP_19004_out > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP_19004_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP_19004_out > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP_1813_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP_67_in > NUL
netsh advfirewall firewall delete rule name=NxFilter_UDP_68_out > NUL
REM ##############################################
echo Adding firewall rules (new names).
netsh advfirewall firewall add rule name=NxFilter_UDP_53_in protocol=UDP dir=in localport=53 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_80_in protocol=TCP dir=in localport=80 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_443_in protocol=TCP dir=in localport=443 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_19002_in protocol=TCP dir=in localport=19002 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_19003_in protocol=TCP dir=in localport=19003 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_19004_in protocol=TCP dir=in localport=19004 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_19003_out protocol=TCP dir=out remoteport=19003 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_TCP_19004_out protocol=TCP dir=out remoteport=19004 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_UDP_19004_in protocol=UDP dir=in localport=19004 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_UDP_19004_out protocol=UDP dir=out remoteport=19004 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_UDP_1813_in protocol=UDP dir=in localport=1813 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_UDP_67_in protocol=UDP dir=in localport=67 action=allow > NUL
netsh advfirewall firewall add rule name=NxFilter_UDP_68_out protocol=UDP dir=out remoteport=68 action=allow > NUL
REM ##############################################
set BPATH=%~dp0
cd %BPATH%
cd ..
REM ##############################################
nxwrapper.exe --startup=auto install
set /p APPNAME=<conf\appname
net start %APPNAME%
cd bin
pause