@echo off

if "%1"=="" (
title RFSN uninstall batch script
echo ---------------------------------------
echo "|  __ \     /\   | \ | |  ____/ ____|"
echo "| |__) |   /  \  |  \| | |__ | (___  "
echo "|  _  /   / /\ \ | . ` |  __| \___ \ "
echo "| | \ \  / ____ \| |\  | |    ____) |"
echo "|_|  \_\/_/    \_\_| \_|_|   |_____/ "
echo ---------------------------------------
)

echo check permissions ....
rd "%WinDir%\system32\test_permissions" >NUL 2>NUL
md "%WinDir%\System32\test_permissions" 2>NUL
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
echo Request admin rights...
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B

:gotAdmin
rd "%WinDir%\System32\test_permissions" 2>NUL

cd /d %~dp0
echo Disable Firewall ...
netsh advfirewall firewall delete rule name=RFSN-SRV 1>NUL

echo uninstall service ....
net stop rfsn 1>NUL
sc delete rfsn 1>NUL

if "%1"=="" ( pause )
