@echo off
title Radmin Server v3.5 汉化破解绿色版 - 安装程序
color 80
echo.
echo      欢迎使用 Radmin Server v3.5 汉化破解绿色版
echo.
echo      绿化制作：Bluefish
echo.
echo      博客地址：http://www.cnblogs.com/radmin
echo.
echo.

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
set MirrorPath=x64
goto Run
exit

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

:Run
rem 生成防火墙白名单规则,兼容XP和2003系统
set FirewallAdd64=netsh advfirewall firewall add rule name="Radmin Server 3" dir=in action=allow program="%RserverPath%\rserver3.exe" enable=yes profile=any
set FirewallDel64=netsh advfirewall firewall delete rule name="Radmin Server 3"
set FirewallAdd86=netsh firewall add allowedprogram program="%RserverPath%\rserver3.exe" name="Radmin Server 3" ENABLE scope=ALL profile=ALL
set FirewallDel86=netsh firewall delete allowedprogram program="%RserverPath%\rserver3.exe" profile=ALL

ver|findstr "5\.[0-9]\.[0-9][0-9]*" > nul && (set FirewallAdd=%FirewallAdd86%&set FirewallDel=%FirewallDel86%&set is32=)  
ver|findstr "6\.[0-9]\.[0-9][0-9]*" > nul && (set FirewallAdd=%FirewallAdd64%&set FirewallDel=%FirewallDel64%&set is32=/reg:32)

%~d0
cd "%~dp0"

if NOT exist %RserverPath%\rserver3.exe (GOTO CopyRadmin35)
echo 卸载已安装的 Radmin Server ...
%RsetupPath% /intuninstall
echo 删除防火墙规则.
%FirewallDel%
echo 删除 radmin server 的注册表配置信息.
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Radmin /f %is32%
echo 卸载破解补丁并清空目录
regsvr32 /s /u %RserverPath%\wsock32.dll
rd /s /q %RserverPath%

:CopyRadmin35
echo 拷贝当前版本的文件到系统目录
if not exist "%RserverPath%" (mkdir %RserverPath%)
copy rserver30\*.* %RserverPath%
copy %MirrorPath%\*.* %RserverPath%

echo 增加到防火墙白名单...
%FirewallAdd%

echo 安装 Radmin Server 服务和虚拟显卡驱动...
%RsetupPath% /intsetup

echo 导入注册表设置...
reg import %RserverPath%\install.reg %is32%

echo 启动 Radmin Server 服务...
%RsetupPath% /start

rem 清理多余文件
del /f /q %RserverPath%\install.reg

exit