@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
)

:: 安装前结束相关进程
@ echo.
echo  正在结束相关进程
taskkill /f /im QQLive.exe >NUL 2>NUL
@ echo.
echo  正在绿化中，请稍等
:: 清理后台相关文件及注册残留
rd/s/q "%APPDATA%\Tencent\DeskUpdate"2>NUL
rd/s/q "%APPDATA%\Tencent\Logs"  2>NUL
rd/s/q "%APPDATA%\Tencent\OMGCACHE"  2>NUL
rd/s/q "%AppData%\Tencent\QQLive\LiveUp"2>NUL
rd/s/q "%AppData%\Tencent\QQLive\MiniTips"2>NUL
rd/s/q "%AppData%\Tencent\QQLive\CacheFile\AD"2>NUL
del/f "%AppData%\Tencent\QQLive\AutoUpdate.conf" >NUL 2>NUL
del/f "%AppData%\Tencent\QQLive\CacheFile\TencentVideo*" >NUL 2>NUL
del/f "%AppData%\Tencent\QQLive\CacheFile\AutoUpdate.conf" >NUL 2>NUL
del/f "%AppData%\Tencent\QQLive\CacheFile\checkupdate.tmp" >NUL 2>NUL
::注册相关组件
regsvr32 /s LiveAPI.dll
regsvr32 /s LiveLogin.dll
start /wait /B "" "%~dp0QQLive.exe" -register
start /wait /B "" "%~dp0QQLive.exe" -reg_video_file
start /wait /B "" "%~dp0QQLive.exe" -cacl
start /wait /B "" "%~dp0QQLive.exe" -WriteCookie
start /wait /B "" "%~dp0QQLive.exe" -PreLoadPlayerModule
regsvr32 /s npQQLive.dll
if exist "%Public%" start /wait /B "" "%~dp0OcxHelper.exe" -drm_path "%ProgramData%\Tencent\QQLive\"
if not exist "%Public%" start /wait /B "" "%~dp0OcxHelper.exe" -drm_path "%AllUsersProfile%\Application Data\Tencent\QQLive\"
start /wait /B "" "%~dp0OcxHelper.exe" -fix_reg -install
start /wait /B "" "%~dp0OcxHelper.exe" -install
:: 复制相关数据
xcopy /s/i/y QQLive "%AppData%\Tencent\QQLive">NUL 2>NUL
:: 设置安装版本号和路径
reg add HKCR\qqtv /f /v install /d "%CD%" >NUL
reg add HKCR\qqtv /f /v installPath /d "%CD%" >NUL
if not exist "%WinDir%\SysWOW64" reg add HKLM\Software\tencent\qqlive /f /v install /d "%~dp0\" >NUL
if not exist "%WinDir%\SysWOW64" reg add HKLM\Software\tencent\qqliveocx /f /v install /d "%~dp0\" >NUL
if not exist "%WinDir%\SysWOW64" reg add HKLM\Software\tencent\qqlive /f /v short_instal /d "%~dp0\" >NUL
if exist "%WinDir%\SysWOW64" reg add HKLM\Software\Wow6432Node\tencent\qqlive /f /v install /d "%~dp0\" >NUL
if exist "%WinDir%\SysWOW64" reg add HKLM\Software\Wow6432Node\tencent\qqliveocx /f /v install /d "%~dp0\" >NUL
if exist "%WinDir%\SysWOW64" reg add HKLM\Software\Wow6432Node\tencent\qqlive /f /v short_instal /d "%~dp0\" >NUL
CLS & ECHO.&ECHO 绿化完成，是否创建桌面快捷方式？
ECHO.&ECHO 是按任意键，否直接关闭窗口即可！&&PAUSE >NUL

mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\腾讯视频.lnk""):b.TargetPath=""%~dp0QQLive.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")

CLS && ECHO.&ECHO 创建完成，按任意键退出！ &&PAUSE>NUL & EXIT