@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 YunDetectSer* >NUL 2>NUL
taskkill /f /im BaiduNetdisk* /t >NUL 2>NUL

regsvr32 /s /u npYunWebDetect.dll
regsvr32 /s /u YunShellExt.dll
regsvr32 /s /u YunShellExt64.dll
regsvr32 /s /u YunShellExtV1.dll
regsvr32 /s /u YunShellExtV164.dll
regsvr32 /s /u YunOfficeAddin.dll
regsvr32 /s /u YunOfficeAddin64.dll
if exist YunDetectService.exe start /wait YunDetectService.exe unreg
taskkill /f /im YunDetectSer* >NUL 2>NUL
if exist BaiduNetdiskHost.exe ren BaiduNetdiskHost.exe  BaiduNetdiskHost.bak >NUL 2>NUL

del /q "cmd.exe" >NUL 2>NUL
del /q "AppProperty.xml" >NUL 2>NUL
del /q "AppSettingApp.dat" >NUL 2>NUL
rd/s/q "%TEMP%\baidu" 2>NUL
rd/s/q "%TEMP%\baiduyunguanjia" 2>NUL
rd/s/q "%TEMP%\bdyunguanjiaskinres"2>NUL
rd/s/q "%AppData%\BaiduYunGuanjia" 2>NUL
rd/s/q "%AppData%\BaiduYunKernel" 2>NUL
rd/s/q "%AppData%\Baidu\BaiduNetdisk" 2>NUL

ver|findstr "5\.[0-9]\.[0-9][0-9]*" >NUL && (
del/q "%UserProfile%\桌面\百度网盘*.lnk" >NUL 2>NUL
del/q "%AllUsersProfile%\桌面\百度网盘*.lnk" >NUL 2>NUL
rd/s/q "%UserProfile%\「开始」菜单\程序\百度网盘"2>NUL
rd/s/q "%AllUsersProfile%\「开始」菜单\程序\百度网盘"2>NUL)
ver|findstr "\<6\.[0-9]\.[0-9][0-9]*\> \<10\.[0-9]\.[0-9][0-9]*\>" >NUL && (
del/q "%Public%\Desktop\百度网盘*.lnk" >NUL 2>NUL
del/q "%UserProfile%\Desktop\百度网盘*.lnk" >NUL 2>NUL
rd/s/q "%AppData%\Microsoft\Windows\Start Menu\Programs\百度网盘"2>NUL
rd/s/q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\百度网盘"2>NUL)

reg delete "HKCR\BaiduYunGuanjia.torrent" /f >NUL 2>NUL
reg delete "HKCU\Software\Baidu\BaiduYunGuanjia" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Baidu\BaiduYunGuanjia" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Baiduyunguanjia" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\BaiduYunGuanjia.torrent" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Baidu\BaiduYunGuanjia" /f /reg:32 >NUL 2>NUL
reg delete "HKCR\CLSID\{679F137C-3162-45da-BE3C-2F9C3D093F64}" /f >NUL 2>NUL
reg delete "HKCR\CLSID\{18701C81-34AB-498E-8C7F-5D26B9C36732}" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\CLSID\{679F137C-3162-45da-BE3C-2F9C3D093F64}" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\CLSID\{18701C81-34AB-498E-8C7F-5D26B9C36732}" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "BaiduYunDetect" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "BaiduYunGuanjia" /f >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "BaiduYunDetect" /f >NUL 2>NUL
reg delete "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "BaiduYunGuanjia" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BaiduNetdisk" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BaiduNetdisk" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{679F137C-3162-45da-BE3C-2F9C3D093F64}" /f >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{18701C81-34AB-498E-8C7F-5D26B9C36732}" /f >NUL 2>NUL
for /f "delims=" %%a in ('wmic userAccount where "Name='%userName%'" get SID /value') do call set "%%a" >nul
reg delete "HKU\%SID%\SOFTWARE\Classes\CLSID\{679F137C-3162-45da-BE3C-2F9C3D093F64}" /f >NUL 2>NUL
reg delete "HKU\%SID%\SOFTWARE\Classes\CLSID\{18701C81-34AB-498E-8C7F-5D26B9C36732}" /f >NUL 2>NUL
reg delete "HKU\%SID%\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{679F137C-3162-45da-BE3C-2F9C3D093F64}" /f >NUL 2>NUL
reg delete "HKU\%SID%\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{18701C81-34AB-498E-8C7F-5D26B9C36732}" /f >NUL 2>NUL
reg delete "HKU\%SID%\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /f /v "{18701C81-34AB-498E-8C7F-5D26B9C36732}" >NUL 2>NUL

CLS
ECHO.&ECHO www.x6d.com
ECHO.&ECHO 清理完成，删除软件？
ECHO.&ECHO 1、删除软件保留登陆信息和设置数据
ECHO.&ECHO 2、删除软件以及登陆信息和设置数据

CHOICE /C 12 /N >NUL 2>NUL

IF "%ERRORLEVEL%"=="2" (
  del/f/q "YunShellExt*.dll" >NUL 2>NUL
  if exist YunShellExt.dll ren YunShellExt.dll "YunShellExt.dll.%time:~6,2%.tmp" >NUL 2>NUL
  if exist YunShellExt64.dll ren YunShellExt64.dll "YunShellExt.dll.%time:~6,2%.tmp" >NUL 2>NUL
  PUSHD .. & RD /S/Q "%~DP0" >NUL 2>NUL)
  
IF "%ERRORLEVEL%"=="1" (
  del/f/q "YunShellExt*.dll" >NUL 2>NUL
  if exist YunShellExt.dll ren YunShellExt.dll "YunShellExt.dll.%time:~6,2%.tmp" >NUL 2>NUL
  if exist YunShellExt64.dll ren YunShellExt64.dll "YunShellExt.dll.%time:~6,2%.tmp" >NUL 2>NUL
  IF EXIST "users" (
  FOR /F "delims=*" %%a IN ('dir /a/b *.*^|findstr /v /i "users$"') DO (
  RD /S/Q "%%a" 2>NUL & DEL /F/Q "%%a" >NUL 2>NUL)
  ) ELSE (
  del/f/q "YunShellExt*.dll" >NUL 2>NUL
  if exist YunShellExt.dll ren YunShellExt.dll "YunShellExt.dll.%time:~6,2%.tmp" >NUL 2>NUL
  if exist YunShellExt64.dll ren YunShellExt64.dll "YunShellExt.dll.%time:~6,2%.tmp" >NUL 2>NUL
  PUSHD .. & RD /S/Q "%~DP0" >NUL 2>NUL))