@echo off
if /i "%UserName%" == "SYSTEM" (Goto GotAdmin) else (reg query "HKLM\SYSTEM\ControlSet001\Control\MiniNT" 1>nul 2>nul&&Goto GotAdmin)
:BatchGotAdmin
Set _Args=%*
if `%1` neq `` Set "_Args=%_Args:"=""%"
if exist %WinDir%\System32\fltMC.exe fltMC 1>nul 2>nul||mshta VBScript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c """"%~f0"" %_Args%""",,"runas",1)(Window.Close) 2>nul&&Exit /b

:GotAdmin
Pushd "%CD%"&cd /d "%~dp0"
Set "SGV=5.5.0.2585"
REM 判断输入参数
Set hint=&Set "Green=%SGV%\_Green"
if /i "%~1" == "uninsta" Goto UnInsta
if /i "%~1" == "fulluni" Goto UnInsta
REM 窗口设置
Title 卸载&(if exist %WinDir%\System32\ureg.dll Mode 36,9 2>nul)&Color 8f
Set hint=启用提示

:UnInsta
if defined hint echo 正在卸载中，请稍候 。。。
net stop SogouWBSvc 1>nul 2>nul&sc delete SogouWBSvc 1>nul 2>nul
reg delete "HKCU\SOFTWARE\SogouWBInput" /f 1>nul 2>nul
reg delete "HKCU\SOFTWARE\SogouWBInput.user" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\SogouWBInput" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\SogouWBInput" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\CTF\TIP\{CC43AF26-60C3-4612-B58D-27A07A40E90C}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\CTF\TIP\{E7EA138F-69F8-11D7-A6EA-00065B844310}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\.cwb" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\AppID\{60E38716-01BE-4AF1-8794-5B090BDA98D6}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\AppID\{E6F5FF31-1BF1-495E-BA47-F24C13CD1602}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\AppID\SogouWBImeBroker.EXE" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\AppID\SogouWBSvc.EXE" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\SogouImeConfig" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\SogouWBImeBroker.SogouWBBroker" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\SogouWBImeBroker.SogouWBBroker.1" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\SogouWBSvc.SGUpdate" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\SogouWBSvc.SGUpdate.1" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\TypeLib\{1B1CE8D6-7EF2-4588-A527-7A2A444744A0}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\TypeLib\{D4E13478-2426-453B-AA7C-DC57667506C3}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{E7EA138F-69F8-11D7-A6EA-00065B844310}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{CC43AF26-60C3-4612-B58D-27A07A40E90C}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{6A498709-E00B-4C45-A018-8F9E4081AE40}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{531FDEBF-9B4C-4A43-A2AA-960E8FCDC732}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{7C472071-36A7-4709-88CC-859513E583A9}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{81EA0A17-AA39-455B-BA20-EA79A8F98966}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{8A829337-30D7-478C-B8AD-41B2B2569468}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{B6891650-D273-4F34-84FF-BAC043EC8956}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{C09F7261-B7DC-401D-8AD9-D9F5679A0E54}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\CLSID\{C2CB2CF0-AF47-413E-9780-8BC3A3C16068}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Interface\{21749A65-B004-4903-8210-344B08EB2F7B}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Interface\{8A829337-30D7-478C-B8AD-41B2B2569468}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{E7EA138F-69F8-11D7-A6EA-00065B844310}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{CC43AF26-60C3-4612-B58D-27A07A40E90C}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{6A498709-E00B-4C45-A018-8F9E4081AE40}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\WOW6432Node\CLSID\{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{531FDEBF-9B4C-4A43-A2AA-960E8FCDC732}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{7C472071-36A7-4709-88CC-859513E583A9}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{81EA0A17-AA39-455B-BA20-EA79A8F98966}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{8A829337-30D7-478C-B8AD-41B2B2569468}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{B6891650-D273-4F34-84FF-BAC043EC8956}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{C09F7261-B7DC-401D-8AD9-D9F5679A0E54}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\CLSID\{C2CB2CF0-AF47-413E-9780-8BC3A3C16068}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\Interface\{21749A65-B004-4903-8210-344B08EB2F7B}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Classes\Wow6432Node\Interface\{8A829337-30D7-478C-B8AD-41B2B2569468}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{109A7614-25A0-423f-A604-A7E31B1BFE58}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{1A84BBB6-E5F7-4325-9891-B90B0844F8FA}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{1CEC7D0B-64A9-4204-817B-6920E013D9F0}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{5015A6FA-0DEB-4369-99FF-6F348B67B3FF}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{6D82CE13-1B9B-4168-92AC-768CEE86B806}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{7F09069C-6CD8-4356-BF16-B67374274707}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{8C5FF5BE-8536-4724-A668-701A7845C212}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{C7F9CD7C-5AC6-470b-A50F-F7CC28D0771C}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{EA4E4267-293B-4819-80E8-81694D27A1B0}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{109A7614-25A0-423f-A604-A7E31B1BFE58}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{1A84BBB6-E5F7-4325-9891-B90B0844F8FA}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{1CEC7D0B-64A9-4204-817B-6920E013D9F0}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{5015A6FA-0DEB-4369-99FF-6F348B67B3FF}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{6D82CE13-1B9B-4168-92AC-768CEE86B806}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{7F09069C-6CD8-4356-BF16-B67374274707}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{8C5FF5BE-8536-4724-A668-701A7845C212}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{C7F9CD7C-5AC6-470b-A50F-F7CC28D0771C}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{EA4E4267-293B-4819-80E8-81694D27A1B0}" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "UserPage.exe" 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" /f /v "UserPage.exe" 1>nul 2>nul
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f 1>nul 2>nul
reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f 1>nul 2>nul
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\SogouWBSvc" /f 1>nul 2>nul
if exist "%SGV%\ScdReg.exe" reg delete "HKLM\SOFTWARE\Classes\SogouCellDict\Entry\SogouWB" /f 1>nul 2>nul
if exist "%SGV%\SkinReg.exe" reg delete "HKLM\SOFTWARE\Classes\SogouSkinFile\Entry\SogouWB" /f 1>nul 2>nul
find /? 1>nul 2>nul&&Set "findstr=find /i "||Set findstr=
findstr /? 1>nul 2>nul&&Set "findstr=findstr /i /c:"
for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Classes\SogouCellDict\Shell\Open\Command" /ve 2^>nul') do echo %%j|%findstr%"%SGV%" 1>nul 2>nul&&(reg delete "HKLM\SOFTWARE\Classes\.scel" /f 1>nul 2>nul&reg delete "HKLM\SOFTWARE\Classes\SogouCellDict" /f 1>nul 2>nul)
for /f "tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Classes\SogouSkinFile\Shell\Open\Command" /ve 2^>nul') do echo %%j|%findstr%"%SGV%" 1>nul 2>nul&&(reg delete "HKLM\SOFTWARE\Classes\.ssf" /f 1>nul 2>nul&reg delete "HKLM\SOFTWARE\Classes\SogouSkinFile" /f 1>nul 2>nul)
Set Layouts=&for /f "delims=" %%i in ('reg query "HKLM\SYSTEM\ControlSet001\Control\Keyboard Layouts" /s /d /f "SogouWB.ime" 2^>nul') do if not defined Layouts Set "Layouts=%%~i"
if /i "%Layouts:~0,2%" == "HK" reg delete "%Layouts%" /f 1>nul 2>nul
REM 系统版本判断
Set OldOS=&Set "SGData=%UserProfile%\AppData\LocalLow"
ver|%findstr%" 5." 1>nul 2>nul&&(Set OldOS=1&Set "SGData=%AppData%")
ver|%findstr%" 6.0" 1>nul 2>nul&&Set OldOS=1
ver|%findstr%" 6.1" 1>nul 2>nul&&Set OldOS=1
if defined OldOS (
    %Green%\IMETool.exe /del3:SogouWB.ime 1>nul 2>nul
    %Green%\IMETool.exe /xxx 1>nul 2>nul
)
:: tskill /? 1>nul 2>nul&&Set "TsKill=tskill"||if exist "%Green%\TsKill.exe" (Set "TsKill=%Green%\TsKill") else Set "TsKill=Pecmd KILL"
:: %TsKill% explorer 1>nul 2>nul
rd /s /q "%SGData%\SogouWB" 1>nul 2>nul
rd /s /q "%SGData%\SogouWB.users" 1>nul 2>nul
rd /s /q "%WinDir%\System32\IME\SogouWB" 1>nul 2>nul
rd /s /q "%WinDir%\SysWOW64\IME\SogouWB" 1>nul 2>nul
del /f /q "%WinDir%\System32\SogouWB.ime" 1>nul 2>nul
del /f /q "%WinDir%\System32\SogouWBTSF.ime" 1>nul 2>nul
del /f /q "%WinDir%\SysWOW64\SogouWB.ime" 1>nul 2>nul
del /f /q "%WinDir%\SysWOW64\SogouWBTSF.ime" 1>nul 2>nul
del /f /q "%WinDir%\System32\test.tmp;" 1>nul 2>nul
del /f /q "%WinDir%\SysWOW64\test.tmp;" 1>nul 2>nul
for /f "tokens=2*" %%i in ('reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Programs" 2^>nul') do Set "Programs=%%~j"
for /f "tokens=3*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Common Programs" 2^>nul') do Set "CPrograms=%%~j"
rd /s /q "%Programs%\搜狗五笔输入法" 1>nul 2>nul
rd /s /q "%CPrograms%\搜狗五笔输入法" 1>nul 2>nul

:End
Set SGCount=0&for %%i in ("%WinDir%\System32\SogouWB.ime" "%WinDir%\SysWOW64\SogouWB.ime") do if exist %%i Set /a SGCount+=1
if %SGCount% gtr 0 Cls&Color cf&echo 文件被占用，请重启后再卸载一次！！&Pause >nul&Exit /b
Set hint=&if /i "%~1" == "fulluni" rd /s /q "%SGV%" 2>nul&del /q install.bat 2>nul&del /q %0 2>nul&cd..&rmdir "%~dp0" 2>nul
Exit /b