@ECHO OFF&(PUSHD "%~DP0")&(REG QUERY "HKU\S-1-5-19">NUL 2>&1)||(
powershell -Command "Start-Process '%~sdpnx0' -Verb RunAs"&&EXIT)

taskkill /f /im QyUpdate.exe /t >NUL 2>NUL
taskkill /f /im QyPlayer.exe /t >NUL 2>NUL
taskkill /f /im QyKernel.exe /t >NUL 2>NUL
taskkill /f /im QyClient.exe /t >NUL 2>NUL
taskkill /f /im QyFragment.exe /t >NUL 2>NUL
taskkill /f /im QIYIClient.exe /t >NUL 2>NUL
taskkill /f /im IQIYIsetup.exe /t >NUL 2>NUL
taskkill /f /im QiyiService.exe /t >NUL 2>NUL

::清除软件相关残留文件
del/f/q "%AppData%\IQIYI Video\LStyle\QyUpdate*" >NUL 2>NUL
rd /s/q "%AppData%\IQIYI Video\LStyle\adsys"  2>NUL
rd/s/q "%CommonProgramFiles(x86)%\IQIYI Video"2>NUL
rd/s/q "%CommonProgramFiles%\IQIYI Video"2>NUL
rd/s/q "%CommonProgramW6432%\IQIYI Video"2>NUL

::清除服务及开机启动项
net stop QiyiService >NUL 2>NUL & sc delete QiyiService >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "QyClient" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "QyClient" >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "HCDNClient" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "HCDNClient" >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "QyFragment" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "QyFragment" >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "QyClient" /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /f /v "HCDNClient" /reg:32 >NUL 2>NUL

::貌似代理脚本支持相关
start /b /min /wait rndhelper.exe GenSnapshot "%~dp0JsEngine.dll" "%~dp0rnd.js" "%~dp0rnd.spst" >NUL 2>NUL

::允许防火墙的入站规则
netsh advfirewall firewall add rule name="爱奇艺视频客户端" dir=in program="%~dp0QyClient.exe" action=allow description="%~dp0QyClient.exe" >NUL 2>NUL
netsh advfirewall firewall add rule name="IQIYI Video Helper" dir=in program="%~dp0QyKernel.exe" action=allow description="%~dp0QyKernel.exe" >NUL 2>NUL
netsh advfirewall firewall add rule name="爱奇艺视频播放器组件" dir=in program="%~dp0QyPlayer.exe" action=allow description="%~dp0QyPlayer.exe" >NUL 2>NUL
netsh advfirewall firewall add rule name="爱奇艺视频辅助程序" dir=in program="%~dp0QyFragment.exe" action=allow description="%~dp0QyFragment.exe" >NUL 2>NUL

::设置选项关闭退出相关
if not exist "%AppData%\IQIYI Video\LStyle" md "%AppData%\IQIYI Video\LStyle" 2>NUL
echo. [BasicSettings] >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL
echo. exit_iqiyi=1 >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL
::复制默认节目列表数据
echo f|copy /y "%~dp0list.db" "%AppData%\IQIYI Video\LStyle" >NUL 2>NUL
::取消选项其它无用开关
echo. [OtherSettings] >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL
echo. big_pop=0 >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL
echo. small_pop=0 >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL
echo. system_message=0 >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL
echo. show_partner_ad=0 >>"%AppData%\IQIYI Video\LStyle\QySetting.ini"2>NUL

IF NOT EXIST "%ProgramW6432%" (
::清除爱奇艺游戏关联项
reg add "HKCU\Software\QyGameClient" /f >NUL 2>NUL
reg add "HKLM\SOFTWARE\Classes\qygameclient" /f >NUL 2>NUL
::关联相关协议调用支持
reg add "HKLM\SOFTWARE\QiYi\QiSu" /f /v "HSetup" /d "1" >NUL 2>NUL
reg add "HKLM\SOFTWARE\QiYi\QiSu" /f /v "HDir" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\SOFTWARE\QiYi\QiSu" /f /v "HKernelPath" /d "%AppData%\IQIYI Video\" >NUL 2>NUL
::解决任务中心打开空白及启用GPU加速
reg add "HKLM\SOFTWARE\Classes\HCDNProxy" /f /ve /d "%~dp0HCDNProxy.dll" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QXClient.exe" /t REG_DWORD /d "11000" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QyClient.exe" /t REG_DWORD /d "11000" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QyFragment.exe" /t REG_DWORD /d "11000" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QyPlayer.exe" /t REG_DWORD /d "11000" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" /f /v "QyClient.exe" /t REG_DWORD /d "1" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" /f /v "QyFragment.exe" /t REG_DWORD /d "1" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" /f /v "QyPlayer.exe" /t REG_DWORD /d "1" >NUL 2>NUL
) ELSE (
reg add "HKLM\SOFTWARE\QiYi\QiSu" /f /v "HSetup" /d "1" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\QiYi\QiSu" /f /v "HDir" /d "%~dp0\" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\QiYi\QiSu" /f /v "HKernelPath" /d "%AppData%\IQIYI Video\" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QXClient.exe" /t REG_DWORD /d "11000" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QyClient.exe" /t REG_DWORD /d "11000" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QyFragment.exe" /t REG_DWORD /d "11000" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "QyPlayer.exe" /t REG_DWORD /d "11000" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" /f /v "QyClient.exe" /t REG_DWORD /d "1" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" /f /v "QyFragment.exe" /t REG_DWORD /d "1" /reg:32 >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_GPU_RENDERING" /f /v "QyPlayer.exe" /t REG_DWORD /d "1" /reg:32 >NUL 2>NUL
)
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\PPStream.exe" /f /ve /d "%~dp0QIYIClient.exe" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\PPStream.exe" /f /v "Path" /d "%~dp0\" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\QyClient.exe" /f /ve /d "%~dp0QIYIClient.exe" >NUL 2>NUL
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\QyClient.exe" /f /v "Path" /d "%~dp0\" >NUL 2>NUL
reg add "HKCR\qips" /f /ve /d "qips播放协议" >NUL 2>NUL
reg add "HKCR\qips" /f /v "URL Protocol" /d "" >NUL 2>NUL
reg add "HKCR\qips\DefaultIcon" /f /ve /d "%~dp0QyClient.exe,-0" >NUL 2>NUL
reg add "HKCR\qips\shell\open\command" /f /ve  /d "\"%~dp0QyClient.exe\" -ppstream \"%%1\"" >NUL 2>NUL
reg add "HKCR\qisu" /f /ve  /d "爱奇艺Windows客户端" >NUL 2>NUL
reg add "HKCR\qisu" /f /v "URL Protocol" /d "" >NUL 2>NUL
reg add "HKCR\qisu\DefaultIcon" /f /ve /d "%~dp0QyClient.exe,-0" >NUL 2>NUL
reg add "HKCR\qisu\shell\open\command" /f /ve /d "\"%~dp0QyClient.exe\" -ppstream \"%%1\"" >NUL 2>NUL

::关联QSV文件类型格式
reg add "HKCR\.pfv" /f /ve /d "pps_pfv" >NUL 2>NUL
reg add "HKCR\.pfv\OpenWithList" /f /ve /d "" >NUL 2>NUL
reg add "HKCR\.pfv\OpenWithProgIds" /f /v "pps_pfv" /t REG_BINARY /d "" >NUL 2>NUL
reg add "HKCR\.pgf" /f /ve /d "爱奇艺缓存文件" >NUL 2>NUL
reg add "HKCR\.pgf\DefaultIcon" /f /ve /d "%~dp0QyClient.exe,-317" >NUL 2>NUL
reg add "HKCR\.pmv" /f /ve /d "爱奇艺下载文件" >NUL 2>NUL
reg add "HKCR\.pmv\DefaultIcon" /f /ve /d "%~dp0QyClient.exe,-148" >NUL 2>NUL
reg add "HKCR\.qsv" /f /ve /d "pps_qsv" >NUL 2>NUL
reg add "HKCR\.qsv\OpenWithList" /f /ve /d "" >NUL 2>NUL
reg add "HKCR\.qsv\OpenWithProgIds" /f /v "pps_qsv" /t REG_BINARY /d "" >NUL 2>NUL
reg add "HKCR\Applications\QyClient.exe\SupportedTypes" /f /v ".pfv" /d "" >NUL 2>NUL
reg add "HKCR\Applications\QyClient.exe\SupportedTypes" /f /v ".qsv" /d "" >NUL 2>NUL
reg add "HKCR\HCDNProxy" /f /ve /d "%~dp0HCDNProxy.dll" >NUL 2>NUL
reg add "HKCR\pps_pfv" /f /ve /d "媒体文件(.pfv)" >NUL 2>NUL
reg add "HKCR\pps_pfv\DefaultIcon" /f /ve  /d "%~dp0QyClient.exe,-107" >NUL 2>NUL
reg add "HKCR\pps_pfv\shell\open" /f /ve  /d "使用 爱奇艺客户端 播放" >NUL 2>NUL
reg add "HKCR\pps_pfv\shell\open\command" /f /ve  /d "\"%~dp0QyClient.exe\" -ppstream \"%%1\"" >NUL 2>NUL
reg add "HKCR\pps_qsv" /f /ve  /d "媒体文件(.qsv)" >NUL 2>NUL
reg add "HKCR\pps_qsv\DefaultIcon" /f /ve  /d "%~dp0QyClient.exe,-107" >NUL 2>NUL
reg add "HKCR\pps_qsv\shell\open" /f /ve  /d "使用 爱奇艺客户端 播放" >NUL 2>NUL
reg add "HKCR\pps_qsv\shell\open\command" /f /ve  /d "\"%~dp0QyClient.exe\" -ppstream \"%%1\"" >NUL 2>NUL

::创建桌面快捷方式
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\爱奇艺视频.lnk""):b.TargetPath=""%~sdp0IQIYIClient.exe"":b.WorkingDirectory=""%~sdp0"":b.Save:close")

ECHO.&ECHO 完成 &TIMEOUT /t 2 >NUL&EXIT