@ECHO OFF & CD /D %~DP0 & TITLE 绿化
>NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
    ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
    ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
    "%TEMP%\Getadmin.vbs"
    DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL
    Exit /b
)

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

net stop QPCore >NUL 2>NUL
sc delete QPCore >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%\QQAppAssistant"2>NUL
rd/s/q "%APPDATA%\Tencent\QQDoctor"2>NUL
rd/s/q "%AppData%\Tencent\DeskUpdate"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
del/f "%AppData%\Tencent\QQCallhx.exe">NUL 2>NUL

rd/s/q "%ProgramData%\QQPet"2>NUL
rd/s/q "%ProgramData%\Tencent\QQProtect"2>NUL
rd/s/q "%CommonProgramFiles%\Tencent\QQProtect"2>NUL
rd/s/q "%CommonProgramFiles(x86)%\Tencent\QQProtect"2>NUL

rd/s/q "%localappdata%\Tencent Files\MiniBrowser"2>NUL
rd/s/q "%UserProfile%\AppData\LocalLow\Tencent Files\Adplus"2>NUL
rd/s/q "%AllUsersProfile%\Application Data\Tencent Files\Adplus"2>NUL

rd/s/q "%UserProfile%\Documents\Tencent"   2>NUL
rd/s/q "%UserProfile%\My Documents\Tencent"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%\Documents\Tencent Files\QPlus"2>NUL
rd/s/q "%UserProfile%\Local Settings\QQKartLiveUpdate"2>NUL
rd/s/q "%UserProfile%\My Documents\Tencent Files\QPlus"2>NUL

rd/s/q "%AllUsersProfile%\Application Data\QQPet"2>NUL
rd/s/q "%AllUsersProfile%\Application Data\Tencent\QQProtect"2>NUL

reg delete HKLM\SYSTEM\CurrentControlSet\Services\QPCore /F>NUL 2>NUL
reg delete HKLM\SYSTEM\CurrentControlSet\services\QQProtect /F>NUL 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)

:: 注册协议：关联网页会话、表情包关联、音乐收听等
if exist Bin\Timwp.dll regsvr32 /s Bin\Timwp.dll
if exist Bin\AppCom.dll regsvr32 /s Bin\AppCom.dll
if exist Bin\Common.dll regsvr32 /s Bin\Common.dll
if exist Bin\TXPFProxy.dll regsvr32 /s Bin\TXPFProxy.dll
if exist Bin\KernelUtil.dll regsvr32 /s Bin\KernelUtil.dll
if exist Bin\TXPlatform.exe Bin\TXPlatform.exe /RegServer
if exist Bin\QQExternal.exe Bin\QQExternal.exe /SetupRegister  
if exist Bin\DownloadProxyPS.dll regsvr32 /s Bin\DownloadProxyPS.dll

:: 注册谷歌、火狐、Opera 快速登陆控件
regsvr32 /s Bin\TXSSO\Npchrome\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

:: 设置安装路劲,安装视频留言和影音播放等组件下载需要
if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add HKLM\Software\Tencent\QQ2009 /f /v Install /d "%~dp0" >NUL
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add HKLM\Software\Wow6432Node\Tencent\QQ2009 /f /v Install /d "%~dp0" >NUL

:: 创建安装版本号,企业类型网页会话需要,CRM组件需保留
if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add HKLM\Software\Tencent\QQ2009 /f /v version /d "56.89.0.26611.0" >NUL
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add HKLM\Software\Wow6432Node\Tencent\QQ2009 /f /v version /d "56.89.0.26611.0" >NUL

:: 判断系统版本号然后去执行添加我的文档自定义路径功能
ver|findstr "5\.[0-9]\.[0-9][0-9]*" > nul && (goto WinXP)
ver|findstr "6\.[0-9]\.[0-9][0-9]*" > nul && (goto Win7+)
ver|findstr "10\.[0-9]\.[0-9][0-9]*" > nul && (goto Win7+)

:WinXP
echo set WshShell = WScript.CreateObject("WScript.Shell")>tmp.vbs
echo set oShellLink = WshShell.CreateShortcut("%~dp0" ^& "\QQ2019.lnk")>>tmp.vbs
echo oShellLink.TargetPath ="%~dp0Bin\QQScLauncher.exe">>tmp.vbs
echo oShellLink.WindowStyle ="1">>tmp.vbs
echo oShellLink.IconLocation = "%~dp0Bin\QQScLauncher.exe">>tmp.vbs
echo oShellLink.Description = "">>tmp.vbs
echo oShellLink.WorkingDirectory = "%~dp0">>tmp.vbs
echo oShellLink.Save>>tmp.vbs
call tmp.vbs & del /f /q tmp.vbs >NUL 2>NUL
ECHO.&ECHO 完成！创建桌面快捷方式？
ECHO.&ECHO 是敲任意键，否直接关闭！&PAUSE >NUL 2>NUL
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")
CLS &ECHO.&ECHO 完成！&PAUSE >NUL 2>NUL & EXIT

:Win7+
:: 生成个人文件夹保存位置配置文件，让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
echo set WshShell = WScript.CreateObject("WScript.Shell")>tmp.vbs
echo set oShellLink = WshShell.CreateShortcut("%~dp0" ^& "\QQ.lnk")>>tmp.vbs
echo oShellLink.TargetPath ="%~dp0Bin\QQScLauncher.exe">>tmp.vbs
echo oShellLink.WindowStyle ="1">>tmp.vbs
echo oShellLink.IconLocation = "%~dp0Bin\QQScLauncher.exe">>tmp.vbs
echo oShellLink.Description = "">>tmp.vbs
echo oShellLink.WorkingDirectory = "%~dp0">>tmp.vbs
echo oShellLink.Save>>tmp.vbs
call tmp.vbs & del /f /q tmp.vbs >NUL 2>NUL
ECHO.&ECHO 完成！创建桌面快捷方式？
ECHO.&ECHO 是敲任意键，否直接关闭！&PAUSE >NUL 2>NUL
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")
CLS &ECHO.&ECHO 完成！&PAUSE >NUL 2>NUL & EXIT