@echo off
title Radmin Server v3.5 卸载程序
color 80

rem 判断64位系统和32位系统
if /i %PROCESSOR_IDENTIFIER:~0,3%==x86 (
	goto x86
) else (
	goto x64
)
exit

:x64
set RserverPath=%windir%\SysWOW64\rserver30
set RsetupPath=%RserverPath%\rsetup64.exe
goto Run
exit

:x86
set RserverPath=%windir%\System32\rserver30
set RsetupPath=%RserverPath%\rsetup.exe
goto Run

:Run
echo 删除服务和虚拟显卡驱动...
%RsetupPath% /intuninstall

rem 生成防火墙白名单规则兼容XP和2003系统
set FirewallDel64=netsh advfirewall firewall delete rule name="Radmin Server 3"
set FirewallDel86=netsh firewall delete allowedprogram program="%RserverPath%\rserver3.exe" profile=ALL
ver|findstr "5\.[0-9]\.[0-9][0-9]*" > nul && (set FirewallDel=%FirewallDel86%&set is32=)  
ver|findstr "6\.[0-9]\.[0-9][0-9]*" > nul && (set FirewallDel=%FirewallDel64%&set is32=/reg:32)
echo 删除防火墙规则.
%FirewallDel%

echo 删除 radmin server 的注册表配置信息.
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Radmin /f %is32%

echo 卸载破解补丁并清空目录
START /B /WAIT rundll32.exe %RserverPath%\wsock32.dll,ntsclean
rd /s /q %RserverPath%
echo.
echo 卸载完成！请重启系统以彻底删除 Radmin Server 虚拟显卡驱动.
echo.
pause