-
Notifications
You must be signed in to change notification settings - Fork 18
/
install.bat
92 lines (91 loc) · 2.91 KB
/
install.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@echo off
if not "%cd%"\=="%~pd0" cd /d "%~pd0"
set target=%1
set dest=%~nx1
if "%target%"=="" (
set target=kbdusru_undead.dll
set dest=kbdusru_undead.dll
set lid=00d0
set id=07430419
set shortname="US+RU"
set longname="United States-International + Russian + Extra"
) else (
set id=07430409
if not "%2"=="" set id=%2
set lid=00d1
if not "%3"=="" set lid=%3
set shortname="US+"
if not "%~4"=="" set shortname=%4
set longname="United States-Custom"
if not "%~5"=="" set longname=%5
)
if not exist %target% goto:notexist
if exist %windir%\system32\%dest% goto:alreadyexist
if exist %windir%\sysnative\cmd.exe goto:relaunch64
call checkdll %target%
if errorlevel 1 goto:eof
net file >nul 2>&1
if not %errorlevel%==0 goto:notadmin
echo Checking keyboard layout IDs, please wait...
call checklid %lid%
if errorlevel 1 goto:eof
set /p answer="Do you want to install %target% in your system? [Y/N] "
if "%answer%"=="" goto:no
if /I "%answer:~0,1%"=="y" goto:yes
:no
echo Cancelled.
goto:eof
:yes
copy %target% %windir%\system32\%dest% >nul 2>&1
if errorlevel 1 goto:cannotcopy
for /f %%i in ('ver ^| %windir%\system32\find "Version 5"') do set nt5=yes
if not exist %windir%\system32\reg.exe goto:manualreg
set key="HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\%id%"
reg add %key% /f >nul 2>&1
if errorlevel 1 goto:cannotreg
reg add %key% /f /v "Layout Text" /t REG_SZ /d %shortname% >nul 2>&1
reg add %key% /f /v "Layout Display Name" /t REG_SZ /d %longname% >nul 2>&1
reg add %key% /f /v "Layout File" /t REG_SZ /d "%dest%" >nul 2>&1
reg add %key% /f /v "Layout Id" /t REG_SZ /d %lid% >nul 2>&1
if errorlevel 1 goto:cannotreg
if not x%nt5%==xyes reg_layout r 0x%id:~4,4%:0x%id%
if errorlevel 1 goto:cannotreg2
echo The job is done. Now you should have additional layout called %longname%
goto:eof
:manualreg
echo REGEDIT4>>_install.reg
echo.>>_install.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\%id%]>>_install.reg
echo "Layout Text"=%shortname%>>_install.reg
echo "Layout Display Name"=%longname%>>_install.reg
echo "Layout File"="%dest%">>_install.reg
echo "Layout Id"="%lid%">>_install.reg
_install.reg
if errorlevel 1 goto:cannotreg
if not x%nt5%==xyes reg_layout r 0x%id:~4,4%:0x%id%
if errorlevel 1 goto:cannotreg2
echo The job is done. Now you should have additional layout called %longname%
goto:eof
:notexist
echo There is no %target% here, compile it first!
goto:eof
:alreadyexist
echo %target% is already installed in the system!
goto:eof
:cannotcopy
echo Error: unable to copy file to system directory.
goto:eof
:cannotreg
echo Error: unable to register the layout (registry).
goto:eof
:cannotreg2
echo Warning: unable to register the layout (input.dll). Do it manually.
control
goto:eof
:notadmin
echo To install, you must run this command with administrative privilegies.
cscript /nologo /e:javascript elevate.js "%~df0" %* >nul
goto:eof
:relaunch64
%windir%\sysnative\cmd.exe /c "%~df0" %*
goto:eof