@echo off

set param1=%1
@echo off
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

cd /d %~dp0
sc stop rfdk 1>NUL 2>NUL 
sc delete rfdk 1>NUL 2>NUL 

rfdk-cli -e exit 1>NUL
rfdk -U 1>NUL

ver | findstr /r /i "5.1.*]" > NUL && goto WinXP
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto x64
if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto x64
if "%PROCESSOR_ARCHITECTURE%"=="x86" goto x86

:x86
drv\devcon_x86 remove root\rfdisk
goto NEXT

:x64
drv\devcon_x64 remove root\rfdisk
goto NEXT

:WinXP
drv\devcon_x86 remove root\rfdisk
goto NEXT

:NEXT
sc delete rfdisk 1>NUL 2>NUL 
del %WinDir%\system32\drivers\rfdisk.sys 2>NUL

if "%param1%"=="" ( pause ) 

