@echo off

if "%1"=="" (
title RFBD 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=RFBD-NBD 1>NUL
netsh advfirewall firewall delete rule name=RFBD-HTTP 1>NUL

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

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