@ECHO OFF&PUSHD %~DP0 &TITLE 绿化和选项
mode con cols=42 lines=22
color 2F
Rd "%WinDir%\system32\test_permissions" >NUL 2>NUL
Md "%WinDir%\System32\test_permissions" 2>NUL||(Echo 请使用右键管理员身份运行！&&PAUSE >NUL&&EXIT)
Rd "%WinDir%\System32\test_permissions" 2>NUL
SetLocal EnableDelayedExpansion
:Menu
Cls
@ echo.
@ echo.　　　　　　   菜 单 选 项
@ echo.     
@ echo.       绿化[必须] → 请输入1           
@ echo.     
@ echo.       创建桌面图标 → 请输入2       
@ echo.      
@ echo.       显示新手机图标[默认] → 请输入3 
@ echo.           
@ echo.       显示旧手机图标 → 请输入4      
@ echo.                  
@ echo.       卸载 → 请输入5               
@ echo.      
set /p xj= 输入数字按回车：
if /i "%xj%"=="1" Goto Install
if /i "%xj%"=="2" Goto Establish
if /i "%xj%"=="3" Goto New phone
if /i "%xj%"=="4" Goto Old phone
if /i "%xj%"=="5" Goto Uninstall
@ echo.
echo      选择无效，请重新输入
ping -n 2 127.1>nul 
goto menu
:Install
@ echo.
ECHO 　　　正在安装中..请稍等..
:: 安装前结束相关进程
taskkill /f /im TXP* >NUL 2>NUL
taskkill /f /im tad* >NUL 2>NUL
taskkill /f /im QQP* >NUL 2>NUL
taskkill /f /im QQC* >NUL 2>NUL
taskkill /f /im QQ.exe >NUL 2>NUL
:: 清理后台相关文件及注册残留
del/f/q "%tmp%\*.tvl">NUL 2>NUL
del/f/q "%tmp%\*.tsd">NUL 2>NUL
del/f/q "%tmp%\ts*.dat">NUL 2>NUL
del/f/q "%tmp%\QQSa*.exe">NUL 2>NUL
rd/s/q "%AppData%\Tencent\QQ"  2>NUL
rd/s/q "%AppData%\Tencent\Logs"2>NUL
rd/s/q "%AppData%\Tencent\Users"2>NUL
rd/s/q "%AppData%\Tencent\QTalk"2>NUL
rd/s/q "%AppData%\Tencent\QQLite"2>NUL
rd/s/q "%APPDATA%\Tencent\QQDoctor"2>NUL
rd/s/q "%AppData%\Tencent\DeskUpdate"2>NUL
rd/s/q "%ProgramData%\Tencent\QQProtect"2>NUL
rd/s/q "%AppData%\Tencent\AndroidAssist"2>NUL
rd/s/q "%AppData%\Tencent\AndroidServer"2>NUL
rd/s/q "%AppData%\Tencent\QQPhoneManager"2>NUL
rd/s/q "%AppData%\Tencent\QQPhoneAssistant"2>NUL
rd/s/q "%UserProfile%\Documents\Tencent"   2>NUL
rd/s/q "%UserProfile%\My Documents\Tencent"2>NUL
rd/s/q "%UserProFile%\AppData\LocalLow\QQMiniDL"2>NUL
rd/s/q "%AllUsersProfile%\Application Data\QQPet"2>NUL
rd/s/q "%UserProfile%\AppData\Local\Tencent\QQPet"2>NUL
rd/s/q "%USERPROFILE%\Local Settings\Tencent\QQPet"2>NUL
rd/s/q "%USERPROFILE%\Local Settings\QQKartLiveUpdate"2>NUL
rd/s/q "%UserProfile%\Documents\Tencent Files\QPlus"   2>NUL
rd/s/q "%UserProfile%\My Documents\Tencent Files\QPlus"2>NUL
rd/s/q "%AllUsersProfile%\Application Data\Tencent\QQProtect"2>NUL
reg delete HKLM\SYSTEM\CurrentControlSet\services\QQProtect /F>NUL 2>NUL
rd/s/q "%CommonProgramFiles%\Tencent\QQProtect"2>NUL
rd/s/q "%CommonProgramFiles(x86)%\Tencent\QQProtect"2>NUL
for /f "skip=2 tokens=3 delims= " %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v personal') do (
       for /f "delims=*" %%j in ('echo %%i') do rd/s/q "%%j\Tencent Files\All Users\QQ\Misc\OperateFace" 2>NUL)
:: 去除表情页上方banner
Set D=%AllUsersProfile%\Documents\Tencent\QQ\UserDataInfo.ini
If Exist %~dp0Users Set UserDataSavePath=%~dp0Users&Goto Write
FOR /F "tokens=1,2,*" %%I IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal"') DO (
  If "%%I"=="Personal" SET UserDataSavePath=%%K\Tencent Files&Goto Write)
For /F "usebackq tokens=1,2 delims==" %%I In ("%D%") DO (
  If "%%I" == "UserDataSavePath" (Set UserDataSavePath=%%J&Goto Write)
)
:Write
IF NOT EXIST "%UserDataSavePath%\All Users\QQ\Misc\" md "%UserDataSavePath%\All Users\QQ\Misc"
IF EXIST "%UserDataSavePath%\All Users\QQ\Misc\OperateFace\" RD /S /Q "%UserDataSavePath%\All Users\QQ\Misc\OperateFace\"
echo.>"%UserDataSavePath%\All Users\QQ\Misc\OperateFace"
:: 注册下载助手登陆库控件（注：不传递到系统公用库并注册则打开它无法登陆)
if not exist "%Windir%\SysWOW64" "%CommonProgramFiles%\Tencent\TXSSO\Bin"2>NUL
if exist "%Windir%\SysWOW64" "%CommonProgramFiles(x86)%\Tencent\TXSSO\Bin"2>NUL
if not exist "%Windir%\SysWOW64" xcopy /i/y/e Bin\TXSSO\Bin "%CommonProgramFiles%\Tencent\TXSSO\Bin">NUL 2>NUL
if exist "%Windir%\SysWOW64" xcopy /i/y/e Bin\TXSSO\Bin "%CommonProgramFiles(x86)%\Tencent\TXSSO\Bin">NUL 2>NUL
if not exist "%Windir%\SysWOW64" regsvr32  /s  "%CommonProgramFiles%\Tencent\TXSSO\Bin\SSOLUIContro.dll"
if exist "%Windir%\SysWOW64" regsvr32  /s  "%CommonProgramFiles(x86)%\Tencent\TXSSO\Bin\SSOLUIContro.dll"
if not exist "%WinDir%\SysWOW64" reg add HKLM\Software\Tencent\TXSSO /v version /d "1.2.4.2" /F>NUL
if exist "%WinDir%\SysWOW64" reg add HKLM\Software\Wow6432Node\Tencent\TXSSO /v version /d "1.2.4.2" /F>NUL
:: 注册谷歌、火狐、Opera 快速登陆控件
regsvr32 /s Bin\TXSSO\npactivex.dll
:: 注册SSO核心库、IE及接口快速登陆控件
regsvr32 /s Bin\TXSSO\Bin\SSOCommon.dll
regsvr32 /s Bin\TXSSO\Bin\npSSOAxCtrlForPTLogin.dll
:: 注册中转站上传，群共享、微云上传控件
regsvr32 /s Plugin\Com.Tencent.NetDisk\Bin\QQDisk\Bin\TXFTNActiveX.dll
::注册QQ相关组件
if exist Bin\Timwp.dll regsvr32  /s Bin\Timwp.dll
if exist Bin\AppCom.dll regsvr32 /s Bin\AppCom.dll
if exist Bin\CPHelper.dll regsvr32 /s Bin\CPHelper.dll
if exist Bin\KernelUtil.dll regsvr32 /s Bin\KernelUtil.dll
if exist Bin\TXPlatform.exe Bin\TXPlatform.exe /RegServer
if exist Bin\QQExterna.exe Bin\QQExterna.exe /SetupRegister
:: 复制相关数据
if not exist "%Windir%\SysWOW64" xcopy /s/i/y Bin\TXSSO\QQProtect "%CommonProgramFiles%\Tencent\QQProtect">NUL 2>NUL
if exist "%Windir%\SysWOW64" xcopy /s/i/y Bin\TXSSO\QQProtect "%CommonProgramFiles(x86)%\Tencent\QQProtect">NUL 2>NUL
xcopy /s/i/y I18N\CSC "%AppData%\Tencent\QQ\Misc\CSC">NUL 2>NUL
:: 生成个人文件夹保存位置配置文件，让Win、Win8或更高版的系统能正常保存自定义路径！
if not exist "%Public%\Documents\Tencent\QQ" md "%Public%\Documents\Tencent\QQ"2>NUL
if not exist "%Public%\Documents\Tencent\QQ\UserDataInfo.ini" echo.>"%Public%\Documents\Tencent\QQ\UserDataInfo.ini"2>NUL
:: 占用后禁止生成
md  "%AppData%\Tencent\QQ\Misc\CSC\2052\7"2>NUL
md "%AppData%\Tencent\QQ\Misc\CSC\2052\9">NUL 2>NUL
md "%AppData%\Tencent\QQ\Misc\CSC\2052\13">NUL 2>NUL
echo.banner>"%AppData%\Tencent\QQ\Misc\CSC\2052\7\4" 2>NUL
echo.superQQ>"%AppData%\Tencent\QQ\Misc\com.tencent.wireless"  2>NUL
echo.NoTipLink> "%AppData%\Tencent\QQ\Misc\CSC\2052\9\18"2>NUL
echo.ClientType> "%AppData%\Tencent\QQ\Misc\CSC\2052\9\18"2>NUL
Attrib +r  "%AppData%\Tencent\QQ\Misc\CSC\2052\7\4" >NUL 2>NUL
Attrib +r  "%AppData%\Tencent\QQ\Misc\CSC\2052\7\5" >NUL 2>NUL
Attrib +r "%AppData%\Tencent\QQ\Misc\CSC\2052\13\7" >NUL 2>NUL
Attrib +r "%AppData%\Tencent\QQ\Misc\CSC\2052\9\18" >NUL 2>NUL
Attrib +r "%AppData%\Tencent\QQ\Misc\CSC\2052\13\16" >NUL 2>NUL
Attrib +r "%AppData%\Tencent\QQ\Misc\CSC\2052\7\21" >NUL 2>NUL
Attrib +r  "%AppData%\Tencent\QQ\Misc\com.tencent.wireless" >NUL 2>NUL
:: 设置安装版本号,企业网页会话需要
reg add HKLM\Software\Tencent\QQ2009 /v version /d "54.79.0.18038.0" /F>NUL
if exist "%WinDir%\SysWOW64" reg add HKLM\Software\Wow6432Node\TENCENT\QQ2009 /v version /d "54.79.0.18038.0" /F>NUL
:: 设置安装路劲,安装视频留言和影音播放组件需要
reg add HKLM\Software\Tencent\QQ2009 /v Install /d "%~dp0\" /F>NUL
if exist "%WinDir%\SysWOW64" reg add HKLM\Software\Tencent\QQ2009 /v Install /d "%~dp0\" /F>NUL
goto Install2
:Establish
:: 创建桌面图标
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\腾讯QQ.lnk""):b.TargetPath=""%~dp0Bin\QQScLauncher.exe"":b.WorkingDirectory=""%~dp0Bin"":b.Save:close")
goto fanhui
:Delete
:New phone
:: 显示新手机图标
xcopy /i/y I18N\9\18 "Misc\CSC\2052\9">NUL 2>NUL
goto fanhui
:Old phone
:: 显示旧手机图标
xcopy /i/y I18N\18 "Misc\CSC\2052\9">NUL 2>NUL
goto fanhui
:Uninstall
@ echo.
echo 　　　正在卸载中..请稍等..
:: 卸载前结束相关进程
taskkill /f /im TXP* >NUL 2>NUL
taskkill /f /im tad* >NUL 2>NUL
taskkill /f /im QQP* >NUL 2>NUL
taskkill /f /im QQC* >NUL 2>NUL
taskkill /f /im QQ.exe >NUL 2>NUL
::清理相关数据
rd/s/q "%ProgramData%\QQPet"2>NUL
rd/s/q "%AppData%\Tencent\QQ"2>NUL
rd/s/q "%AppData%\QXiu Files"2>NUL
rd/s/q "%AppData%\Tencent\TXSSO"2>NUL
rd/s/q "%AppData%\Tencent\STemp"2>NUL
rd/s/q "%AppData%\Tencent\Users"2>NUL
rd/s/q "%AppData%\Tencent\QTalk"2>NUL
rd/s/q "%AppData%\QQAppAssistant"2>NUL
rd/s/q "%AppData%\Tencent\QQMiniDL"2>NUL
rd/s/q "%AppData%\Tencent\DeskUpdate"2>NUL
rd/s/q "%AppData%\Tencent\QzoneMusic"2>NUL
rd/s/q "%AppData%\Tencent\AndroidAssist"2>NUL
rd/s/q "%AppData%\Tencent\QQPhoneManager"2>NUL
rd/s/q "%ProgramData%\Tencent\QQProtect" 2>NUL
rd/s/q "%UserProFile%\AppData\LocalLow\QQMiniDL"2>NUL
rd/s/q "%UserProfile%\AppData\Local\Tencent\Misc"2>NUL
rd/s/q "%AllUsersProfile%\Application Data\QQPet"2>NUL
rd/s/q "%UserProfile%\AppData\Local\Tencent\QQPet"2>NUL
rd/s/q "%USERPROFILE%\Local Settings\Tencent\QQPet"2>NUL
rd/s/q "%USERPROFILE%\Local Settings\QQKartLiveUpdate"2>NUL
rd/s/q "%AllUsersProfile%\Application Data\Tencent\QQProtect"2>NUL
rd/s/q "%CommonProgramFiles%\Tencent\QQProtect"2>NUL
rd/s/q "%CommonProgramFiles(x86)%\Tencent\QQProtect"2>NUL
for /f "skip=2 tokens=3 delims= " %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v personal') do (
       for /f "delims=*" %%j in ('echo %%i') do rd/s/q "%%j\Tencent Files\All Users\QQ\Misc\OperateFace" 2>NUL)
::卸载所有控件
regsvr32 /s /u Bin\TXSSO\Bin\SSOCommon.dll
regsvr32 /s /u Bin\TXSSO\Bin\npactivex.dll
regsvr32 /s /u Bin\TXSSO\TXFTN\TXFTNActiveX1.17.dll
regsvr32 /s /u Bin\TXSSO\Bin\npSSOAxCtrlForPTLogin.dll
if exist Bin\Timwp.dll regsvr32 /s /u Bin\Timwp.dll
if exist Bin\AppCom.dll regsvr32 /s /u Bin\AppCom.dll
if exist Bin\CPHelper.dll regsvr32 /s /u Bin\CPHelper.dll
if exist Bin\TXPFProxy.dll regsvr32 /s /u Bin\TXPFProxy.dll
if exist Bin\KernelUtil.dll regsvr32 /s /u Bin\KernelUtil.dll
if exist Bin\TXPlatform.exe Bin\TXPlatform.exe /UnregServer
regsvr32 /s /u Plugin\Com.Tencent.NetDisk\Bin\QQDisk\Bin\TXFTNActiveX.dll
if not exist "%Windir%\SysWOW64" regsvr32 /s /u "%CommonProgramFiles%\Tencent\TXSSO\Bin\SSOLUIControl.dll"
if exist "%Windir%\SysWOW64" regsvr32 /s /u "%CommonProgramFiles(x86)%\Tencent\TXSSO\Bin\SSOLUIControl.dll"
::删除注册表键值
reg delete HKLM\Software\Classes\QQPet /F>NUL 2>NUL
reg delete HKCU\Software\Tencent\Plugin /F  >NUL 2>NUL
reg delete HKCU\Software\Tencent\QQ2009 /F  >NUL 2>NUL
reg delete HKLM\Software\Tencent\QQ2009 /F  >NUL 2>NUL
reg delete HKCU\Software\Classes\Tencent /F >NUL 2>NUL
reg delete HKLM\Software\Classes\Tencent /F >NUL 2>NUL
reg delete HKCU\Software\Tencent\QQProtect /F>NUL 2>NUL
reg delete HKCU\Software\Classes\EMOTION.File /F    >NUL 2>NUL
reg delete HKCU\Software\Classes\EMOTION.Package /F >NUL 2>NUL
reg delete HKCU\Software\Tencent\AndroidAssistant /F>NUL 2>NUL
reg delete HKLM\SOFTWARE\Wow6432Node\Classes\QQPet /F>NUL 2>NUL
reg delete HKLM\Software\Wow6432Node\Tencent\QQ2009 /F>NUL 2>NUL
reg delete HKLM\Software\Wow6432Node\Classes\Tencent /F>NUL 2>NUL
reg delete HKLM\SYSTEM\CurrentControlSet\services\QQProtect /F>NUL 2>NUL
::删除桌面图标(只支持系统默认桌面位置)
del /q "%userprofile%\桌面\腾讯QQ.lnk" >NUL 2>NUL
del /q "%userprofile%\Desktop\腾讯QQ.lnk" >NUL 2>NUL
goto Uninstall2
:fanhui
@ ECHO.
ECHO 　　　设置完成..
ping -n 2 10>nul
goto menu
:Install2
@ ECHO.
ECHO 　　　安装完成..
ping -n 2 10>nul
goto menu
:Uninstall2
@ ECHO.
ECHO 　　　卸载完成..
ping -n 2 10>nul
goto menu