@Echo Off&Title 维棠下载器
cd /d %~dp0
mode con cols=42 lines=22
color 2F
>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
)
:Menu
Cls
Echo.
Echo.&Echo     绿化 → 1
Echo.&Echo     卸载 → 2
Echo.
:Menu
Set /p a=输入数字按回车：
If "%a%"=="1" Goto Install
If "%a%"=="2" Goto Uninstall
Echo.&Echo                输入无效，请重新输入！
ping -n 2 127.1 >nul
Goto Menu

:Install
taskkill /f /im ViDown.exe >nul 2>nul
regsvr32 /s VdCom.ocx
if exist "%WinDir%\SysWOW64" regsvr32 /s VdCom64.ocx
reg add "HKCU\Software\Microsoft\Internet Explorer\MenuExt\用【维棠】下载视频" /ve /d "%~dp0vd_link.htm" /f >nul
reg add "HKCU\Software\Microsoft\Internet Explorer\MenuExt\用【维棠】下载视频" /v "Contexts" /t REG_DWORD /d "0x00000063" /f >nul
reg add "HKCU\Software\Microsoft\Internet Explorer\MenuExt\用【维棠】下载全部链接" /ve /d "%~dp0vd_linkall.htm" /f >nul
reg add "HKCU\Software\Microsoft\Internet Explorer\MenuExt\用【维棠】下载全部链接" /v "Contexts" /t REG_DWORD /d "0x000000f3" /f >nul
if "%PROCESSOR_ARCHITECTURE%"=="x86" reg add "HKLM\SOFTWARE\MozillaPlugins\@vidown.cn/npvidown;version=1.0.0.1" /v "Path" /d "%~dp0npvidown.dll" /f >nul
If "%PROCESSOR_ARCHITECTURE%"=="AMD64" reg add "HKLM\SOFTWARE\Wow6432Node\MozillaPlugins\@vidown.cn/npvidown;version=1.0.0.1" /v "Path" /d "%~dp0npvidown.dll" /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ViDown.exe" /v "Path" /d "%~dp0\" /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ViDown.exe" /ve /d "%~dp0ViDown.exe" /f >nul
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\维棠下载器.lnk""):b.TargetPath=""%~dp0ViDown.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")
Goto fanhui

:Uninstall
taskkill /f /im ViDown.exe >nul 2>nul
rd /s /q "%AppData%\ViDown" >nul 2>nul
regsvr32 /s /u VdCom.ocx
if exist "%WinDir%\SysWOW64" regsvr32 /s /u VdCom64.ocx
reg delete "HKCU\Software\Microsoft\Internet Explorer\MenuExt\用【维棠】下载视频" /f >nul 2>nul
reg delete "HKCU\Software\Microsoft\Internet Explorer\MenuExt\用【维棠】下载全部链接" /f >nul 2>nul
reg delete "HKLM\SOFTWARE\MozillaPlugins\@vidown.cn/npvidown;version=1.0.0.1" /f >nul 2>nul
reg delete "HKLM\SOFTWARE\Wow6432Node\MozillaPlugins\@vidown.cn/npvidown;version=1.0.0.1" /f >nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ViDown.exe" /f >nul 2>nul
del /q "%userprofile%\Desktop\维棠下载器.lnk" >nul 2>nul
del /q "%userprofile%\桌面\维棠下载器.lnk" >nul 2>nul
Goto fanhui

:fanhui
Echo.&Echo                完成...
ping -n 2 10>nul
goto menu

