@echo off & setlocal enabledelayedexpansion
if exist "C:\Progra~1\WinRAR\Rar.exe" (
set RarPath="C:\Progra~1\WinRAR\Rar.exe"
) else (
if exist "%ProgramFiles%\WinRAR\Rar.exe" set RarPath="%ProgramFiles%\WinRAR\Rar.exe"
)
if not defined RarPath call :Find
echo %RarPath% 
Copy %RarPath% rar.exe
echo 安装RAR压缩插件完成
pause

:Find
reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe" %temp%\_.reg
for /f "skip=4 delims== tokens=2" %%a in ('type %temp%\_.reg') do (
set RarPath=%%~a
call set RarPath="%%RarPath:\\=\%%\Rar.exe"
)
del %temp%\_.reg