pushd "%~dp0" && Dism 1>nul 2>nul || mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 "%*"","","runas",1)(window.close) && Exit /B 1
echo off

taskkill /f /im Xshell* >NUL 2>NUL
taskkill /f /im Xftp* >NUL 2>NUL
taskkill /f /im Xmanager* >NUL 2>NUL

::移除许可服务组件
net stop "FlexNet Licensing Service" >NUL 2>NUL
sc delete "FlexNet Licensing Service" >NUL 2>NUL
rd/s/q "%CommonProgramFiles%\Macrovision Shared"2>NUL
rd/s/q "%CommonProgramFiles(x86)%\Macrovision Shared"2>NUL
reg delete "HKCU\Software\Microsoft\NetLicense" /F /reg:32 >NUL 2>NUL
reg delete "HKCU\Software\Microsoft\NetLicense" /F /reg:32 >NUL 2>NUL

::清除软件相关数据
regsvr32 /s /u NsCopyHook3.dll
rd/s/q "%ProgramData%\NetSarang" 2>NUL
rd/s/q "%AllUsersProfile%\NetSarang\Xftp"2>NUL
rd/s/q "%AllUsersProfile%\NetSarang\Xshell"2>NUL
rd/s/q "%AllUsersProfile%\NetSarang\Xmanager"2>NUL

::清除桌面和开始菜单快捷方式
::XP
ver|findstr "5\.[0-9]\.[0-9][0-9]*" >NUL && (
del/q "%UserProfile%\桌面\Xshell*.lnk" >NUL 2>NUL
del/q "%AllUsersProfile%\桌面\Xshell*.lnk" >NUL 2>NUL
del/q "%UserProfile%\桌面\Xftp*.lnk" >NUL 2>NUL
del/q "%AllUsersProfile%\桌面\Xftp*.lnk" >NUL 2>NUL
del/q "%UserProfile%\桌面\Xmanager*.lnk" >NUL 2>NUL
del/q "%AllUsersProfile%\桌面\Xmanager*.lnk" >NUL 2>NUL )
::win7/8/8.1/10/11
ver|findstr "\<6\.[0-9]\.[0-9][0-9]*\> \<10\.[0-9]\.[0-9][0-9]*\>" >NUL && (
del/q "%Public%\Desktop\Xshell*.lnk" >NUL 2>NUL
del/q "%UserProfile%\Desktop\Xshell*.lnk" >NUL 2>NUL
del/q "%Public%\Desktop\Xftp*.lnk" >NUL 2>NUL
del/q "%UserProfile%\Desktop\Xftp*.lnk" >NUL 2>NUL
del/q "%Public%\Desktop\Xmanager*.lnk" >NUL 2>NUL
del/q "%UserProfile%\Desktop\Xmanager*.lnk" >NUL 2>NUL )

reg delete "HKCU\Software\NetSarang\Xftp" /F /reg:32 >NUL 2>NUL
reg delete "HKCU\Software\NetSarang\Xshell" /F /reg:32 >NUL 2>NUL
reg delete "HKCU\Software\NetSarang\Xmanager" /F /reg:32 >NUL 2>NUL
reg delete "HKCU\Software\Microsoft\NetLicense" /F /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\NetSarang\Common" /F /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\NetSarang\Xftp" /F /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\NetSarang\Xshell" /F /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\NetSarang\Xmanager" /F /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls" /v "%~dp0XshellCore.tlb" /f /reg:32 >NUL 2>NUL

reg delete "HKLM\SOFTWARE\Classes\.xfp" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\.xsh" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\.xts" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\.xcas" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\.xdts" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\TypeLib\{76F8E8FE-E047-44E6-80B1-302E70CB6B27}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{28CDE56E-0823-4779-846E-EF8279D08F48}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{3C46F82A-A7E8-411D-8CBD-348A8F637DEB}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{412941DD-D839-4F04-964A-B848505BED0F}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{6C51A006-7BBF-4CB5-97BA-BE817AE8F676}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{C5F52903-5CCF-4045-A3FD-38C96AFEE001}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{E07D3360-0EB9-40CF-97BD-C3FD867F76DB}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Interface\{F9BEB160-712F-4DEE-AF53-6920B63D699B}" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Xftp.xfp" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Xshell.xsh" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Xtransport.xts" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Xshell.Document" /F/reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Xstart.session" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Classes\Xmanager.session" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Xactivator.exe" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Xagent.exe" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Xftp.exe" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Xshell.exe" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Xrcmd.exe" /f /reg:32 >NUL 2>NUL
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Xmanager.exe" /f /reg:32 >NUL 2>NUL

CLS
ECHO.&ECHO 清除完成，删除主机数据?[敲1]

CHOICE /C 1 /N /reg:32 >NUL 2>NUL
IF "%ERRORLEVEL%"=="1" (
  FOR /F "skip=2 tokens=3 " %%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\NetSarang" /reg:32 >NUL 2>NUL & rd /s/q "%%j\NetSarang Computer" /reg:32 >NUL 2>NUL)
  ECHO.&ECHO 完成 &TIMEOUT /t 2 >NUL&EXIT )