@ECHO OFF
SET APPNAME=Foxmail 绿色版管理脚本
SET APPURL=https://www.portablesoft.org/foxmail/
Title %APPNAME% & Color 2F
CD "%SystemRoot%\system32"
CALL :CHECKADMIN
CD /D "%~dp0"
:INIT
ECHO.
ECHO %APPNAME%
ECHO.
ECHO 脚本作者: 黯然过客
ECHO 发布地址: %APPURL%
ECHO.
ECHO 选择要执行的操作:
ECHO.
ECHO  1 绿化安装
ECHO  2 彻底卸载
ECHO  3 检查更新
ECHO  4 退出脚本
ECHO.
SET /p ACTION="请输入操作序号："
IF "%ACTION%"=="1" GOTO INSTALL
IF "%ACTION%"=="2" GOTO UNINSTALL
IF "%ACTION%"=="3" GOTO UPDATECHECK
IF "%ACTION%"=="4" GOTO END
CLS
GOTO INIT
:INSTALL
REGSVR32 /S "%~dp07.2.17.57\FMPreview.dll"
:: End INSTALL
CLS
ECHO.
ECHO 设置完成 by 黯然过客@www.PortableSoft.org
ECHO.
PAUSE
EXIT
:UNINSTALL
TASKKILL /IM Foxmail.exe /T /F
REGSVR32 /U /S "%~dp07.2.17.57\FMPreview.dll"
RD /S /Q "%APPDATA%\Foxmail7"
REG DELETE "HKLM\SOFTWARE\Classes\Foxmail" /F
REG DELETE "HKLM\SOFTWARE\Classes\Foxmail.Url.mailto" /F
REG DELETE "HKLM\SOFTWARE\Classes\Foxmail.eml" /F
REG DELETE "HKCU\Software\Aerofox\FoxmailPreview" /F
REG DELETE "HKCU\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Clients\Mail\Foxmail" /F
REG ADD "HKCU\Software\Clients\Mail" /VE /D "" /F
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "Foxmail" /F
REG DELETE "HKLM\SOFTWARE\Clients\Mail\Foxmail" /F
REG DELETE "HKLM\Software\Aerofox\FoxmailPreview" /F
REG DELETE "HKLM\SOFTWARE\Classes\Foxmail.Url.mailto" /F
REG DELETE "HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store" /V "%~dp0Foxmail.exe" /F
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FeatureUsage\AppSwitched" /V "%~dp0Foxmail.exe" /F
:: End UNINSTALL
CLS
ECHO.
ECHO 彻底清理完毕 by 黯然过客@www.PortableSoft.org
ECHO.
PAUSE
EXIT
:UPDATECHECK
START %APPURL%
CLS
EXIT
:END
CLS
EXIT
:CHECKADMIN
REG QUERY "HKU\S-1-5-19\Environment"
IF NOT %ERRORLEVEL% EQU 0 (
	CLS
	ECHO.
	ECHO 需要管理员权限才能执行 ...
	ECHO.
	ECHO 请右键单击本脚本文件选择「以管理员身份运行」
	ECHO.
	PAUSE & EXIT
)
CLS
GOTO:EOF