@echo off
title 暗安全兴趣小组  [https://duiz.net]
mode con: cols=70 lines=20
color 0a

rem 获取管理员权限
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"

echo 正在安装搜狗拼音输入法
start "" /wait %~dp0File\搜狗拼音输入法.exe /S

echo 正在安装搜狗五笔输入法
start "" /wait %~dp0File\搜狗五笔输入法.exe /S

echo 正在安装搜狗输入法词库
rem 必须先安装输入法，再安装词库。
start "" /wait %~dp0File\搜狗词库.exe

rem 设置搜狗输入法的一些属性
ren "%ProgramData%\Microsoft\Windows\Start Menu\Programs\搜狗输入法" "搜狗拼音输入法" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "DisplayName" /t REG_SZ /d "搜狗拼音输入法" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "UninstallString" /t REG_SZ /d "C:\Program Files (x86)\SogouInput\11.5.0.5352\Uninstall.exe" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "DisplayIcon" /t REG_SZ /d "C:\Program Files (x86)\SogouInput\11.5.0.5352\SGTool.exe" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "DisplayVersion" /t REG_SZ /d "11.5.0.5352" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "URLInfoAbout" /t REG_SZ /d "https://duiz.net" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "HelpLink" /t REG_SZ /d "https://duiz.net" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou Input" /f /v "Publisher" /t REG_SZ /d "Sogou.com" >NUL 2>NUL
del /q "C:\Program Files (x86)\SogouWBInput\5.5.0.2582\星空软件站.url" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "DisplayName" /t REG_SZ /d "搜狗五笔输入法" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "UninstallString" /t REG_SZ /d "C:\Program Files (x86)\SogouWBInput\5.5.0.2582\Uninstall.exe" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "DisplayIcon" /t REG_SZ /d "C:\Program Files (x86)\SogouWBInput\5.5.0.2582\WbConfig.exe" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "DisplayVersion" /t REG_SZ /d "5.5.0.2582" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "URLInfoAbout" /t REG_SZ /d "https://duiz.net" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "HelpLink" /t REG_SZ /d "https://duiz.net" >NUL 2>NUL
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Sogou WBInput" /f /v "Publisher" /t REG_SZ /d "Sogou.com" >NUL 2>NUL

echo 首先清空输入法列表
reg delete "HKCU\Control Panel\International\User Profile\zh-Hans-CN" /f >NUL 2>NUL
echo 删除微软拼音输入法
reg delete "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000003" /f >NUL 2>NUL
reg delete "HKCU\Software\Microsoft\CTF\TIP\{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}" /f >NUL 2>NUL
echo 删除微软五笔输入法
reg delete "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000003" /f >NUL 2>NUL
reg delete "HKCU\Software\Microsoft\CTF\TIP\{6A498709-E00B-4C45-A018-8F9E4081AE40}" /f >NUL 2>NUL

echo 设置语言栏输入法排序
rem 在Windows设置里添加美国键盘的英语，并设置为第一位
reg add "HKCU\Control Panel\International\User Profile" /v "InputMethodOverride" /t REG_SZ /d "0804:00000409" /f >NUL 2>NUL
rem 设置页面输入法排序，1表示第一位
reg add "HKCU\Control Panel\International\User Profile\zh-Hans-CN" /v "0804:00000409" /t REG_DWORD /d "1" /f >NUL 2>NUL
rem 设置页面输入法排序，搜狗拼音，设置第二位
reg add "HKCU\Control Panel\International\User Profile\zh-Hans-CN" /v "0804:{E7EA138E-69F8-11D7-A6EA-00065B844310}{E7EA138F-69F8-11D7-A6EA-00065B844311}" /t REG_DWORD /d "2" /f >NUL 2>NUL
rem 设置页面输入法排序，搜狗五笔，设置第三位
reg add "HKCU\Control Panel\International\User Profile\zh-Hans-CN" /v "0804:{E7EA138F-69F8-11D7-A6EA-00065B844310}{E7EA1390-69F8-11D7-A6EA-00065B844311}" /t REG_DWORD /d "3" /f >NUL 2>NUL

rem 清空现有语言栏列表
reg delete "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}" /f >NUL 2>NUL
rem 言栏输入法排序，设置美国键盘的英语为第一位
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000000" /v "CLSID" /t REG_SZ /d "{00000000-0000-0000-0000-000000000000}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000000" /v "Profile" /t REG_SZ /d "{00000000-0000-0000-0000-000000000000}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000000" /v "KeyboardLayout" /t REG_DWORD /d "67700740" /f >NUL 2>NUL
rem 言栏输入法排序，搜狗拼音，设置第二位
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000001" /v "CLSID" /t REG_SZ /d "{E7EA138E-69F8-11D7-A6EA-00065B844310}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000001" /v "Profile" /t REG_SZ /d "{E7EA138F-69F8-11D7-A6EA-00065B844311}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000001" /v "KeyboardLayout" /t REG_DWORD /d "0" /f >NUL 2>NUL
rem 言栏输入法排序，搜狗五笔，设置第三位
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000002" /v "CLSID" /t REG_SZ /d "{E7EA138F-69F8-11D7-A6EA-00065B844310}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000002" /v "Profile" /t REG_SZ /d "{E7EA1390-69F8-11D7-A6EA-00065B844311}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\SortOrder\AssemblyItem\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}\00000002" /v "KeyboardLayout" /t REG_DWORD /d "0" /f >NUL 2>NUL

echo 固定键盘布局，防止万象篡改输入法！
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -command "& {get-WinUserLanguageList | Set-WinUserLanguageList -Force}" >NUL 2>NUL

rem 使用 d0000804 键盘布局替换掉 00000804 键盘布局，解决打字出现问号或者游戏中无法打字的情况。
reg delete "HKCU\Keyboard Layout" /f >NUL 2>NUL
reg add "HKCU\Keyboard Layout\Preload" /v "1" /t REG_SZ /d "d0000804" /f >NUL 2>NUL
rem 使用 "美式键盘" 替换掉默认的 "简体中文"
reg add "HKCU\Keyboard Layout\Substitutes" /v "d0000804" /t REG_SZ /d "00000409" /f >NUL 2>NUL
rem 设置 "美式键盘" 为默认输入法
reg add "HKCU\Software\Microsoft\CTF\Assemblies\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}" /v "Default" /t REG_SZ /d "{00000000-0000-0000-0000-000000000000}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\Assemblies\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}" /v "Profile" /t REG_SZ /d "{00000000-0000-0000-0000-000000000000}" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\Assemblies\0x00000804\{34745C63-B2F0-4784-8B67-5E12C8701A31}" /v "KeyboardLayout" /t REG_DWORD /d "67700740" /f >NUL 2>NUL
reg add "HKCU\Software\Microsoft\CTF\HiddenDummyLayouts" /v "00000804" /t REG_SZ /d "00000804" /f >NUL 2>NUL

shutdown -r -t 5 /c "输入法安装完成，5秒后重新启动。"