-
Notifications
You must be signed in to change notification settings - Fork 3
/
DisplayLanguageSwitcher.cmd
536 lines (476 loc) · 16.5 KB
/
DisplayLanguageSwitcher.cmd
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
@echo off
%windir%\system32\reg.exe query "HKU\S-1-5-19" 1>nul 2>nul || (set MESSAGE=ERROR: Run %~nx0 as administrator&goto :END)
if exist "%windir%\winsxs\pending.xml" (set MESSAGE=pending update operation detected, restart the system first to clear it&goto :END)
for /f "tokens=4,5,6,7 delims=~." %%i in ('dir /b %windir%\servicing\Packages\Microsoft-Windows-Foundation-Package*~~*.mum') do set version=%%i.%%j.%%k.%%l&set build=%%k
if %build% lss 7601 (set MESSAGE=ERROR: Only Windows 7 SP1 or later is supported&goto :END)
echo ============================================================
echo Loading System Information
echo ============================================================
echo.
setlocal EnableDelayedExpansion
IF /I "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" (set "arch=64-bit") ELSE (set "arch=32-bit")
for /f "skip=2 tokens=2*" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') do set "product=%%j"
for /f "tokens=3 delims=: " %%i in ('dism /English /Online /Get-CurrentEdition ^| find /i "Current Edition :"') do set "edition=%%i"
for /f "tokens=5 delims=: " %%i in ('dism /English /Online /Get-Intl ^| findstr /C:"UI language :"') do set "uilang=%%i"
for /f %%i in ('dir /b %windir%\servicing\Packages\Microsoft-Windows-Client-LanguagePack-Package~*.mum') do (call set /a _l+=1)
if %_l% gtr 1 for /f "tokens=4 delims=~" %%i in ('dir /b %windir%\servicing\Packages\Microsoft-Windows-Client-LanguagePack-Package~*.mum') do (
if defined uilangs (call set "uilangs=!uilangs! %%i") else (call set "uilangs=%%i")
call :setcount %%i
)
if /i %edition%==Starter goto :Supported
if /i %edition%==HomeBasic goto :Supported
if /i %edition%==HomePremium goto :Supported
if /i %edition%==Professional if %build%==7601 goto :Supported
if /i %edition%==StarterN goto :Supported
if /i %edition%==HomeBasicN goto :Supported
if /i %edition%==HomePremiumN goto :Supported
if /i %edition%==ProfessionalN if %build%==7601 goto :Supported
if /i %edition%==CoreSingleLanguage goto :Supported
:NotSupported
cls
echo ============================================================
echo Operating System Information
echo ============================================================
echo Version : %version%
echo Architecture : %arch%
echo Edition ID : %edition%
echo Name : %product%
if %_l% gtr 1 (
echo Display Languages : %uilangs%
echo Primary Language : %uilang%
) else (
echo Display Language : %uilang%
)
echo.
echo ============================================================
echo This script supports the following Editions:
echo.
echo Windows 7 (Starter, Home Basic, Home Premium, Professional)
echo Windows 8 Single Language
echo Windows 8.1 Single Language
echo Windows 10 Home Single Language
echo.
echo.
echo For other Editions you can run lpksetup.exe to install language packs
echo.
echo Press any key to exit.
pause >nul
goto :eof
:setcount
set /a count+=1
set UIL%count%=%1
goto :eof
:Supported
cd /d "%~dp0"
set _c=0
if %build% equ 7601 if exist "LangPack\*kb2483139*.exe" (for /f "delims=" %%i in ('dir /b LangPack\*kb2483139*.exe') do (call set /a _c+=1))
if exist "LangPack\*.cab" (for /f "delims=" %%i in ('dir /b LangPack\*.cab') do (call set /a _c+=1))
if %_c% neq 1 goto :Info
if %build% equ 7601 if exist "LangPack\*kb2483139*.exe" (for /f "delims=" %%i in ('dir /b LangPack\*kb2483139*.exe') do (set "LangFile=LangPack\%%i"&goto :Check))
for /f "delims=" %%i in ('dir /b LangPack\*.cab') do (set "LangFile=LangPack\%%i")
:Check
echo.
echo ============================================================
echo Loading Language Pack Information
echo ============================================================
echo.
if %build% equ 7601 if /i "%LangFile:~-3%"=="exe" (
LangPack\exe2cab.exe -q "%LangFile%" "LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab"
set "LangFile=LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab"
)
expand.exe -f:langcfg.ini "%LangFile%" "%cd%" >nul
for /f "tokens=2 delims==" %%i in ('findstr /i "Language" "%cd%\langcfg.ini"') do (set "LangCode=%%i")
for /f "tokens=3 delims==x" %%i in ('findstr /i "Type" "%cd%\langcfg.ini"') do set LangType=%%i
del /f /q "%cd%\langcfg.ini"
if %build% equ 7601 expand.exe -f:Microsoft-Windows-Client-LanguagePack-Package*%PROCESSOR_ARCHITECTURE%*%version%.mum "%LangFile%" "%cd%" 1>nul 2>nul
if %build% equ 9600 expand.exe -f:Microsoft-Windows-Client-LanguagePack-Package*%PROCESSOR_ARCHITECTURE%*%version%.mum "%LangFile%" "%cd%" 1>nul 2>nul
if %build% equ 9200 expand.exe -f:Microsoft-Windows-Common-Foundation-Package*%PROCESSOR_ARCHITECTURE%*%version%.mum "%LangFile%" "%cd%" 1>nul 2>nul
if %build% gtr 9600 expand.exe -f:Microsoft-Windows-Common-Foundation-Package*%PROCESSOR_ARCHITECTURE%*%version%.mum "%LangFile%" "%cd%" 1>nul 2>nul
if not exist "%cd%\*.mum" (set MESSAGE=ERROR: Lang Pack is not compatible with current OS version and architecture&goto :END)
del /f /q "%cd%\*.mum" 1>nul 2>nul
call :%LangCode%
:Info
cls
set userinp=
echo ============================================================
echo Operating System Information
echo ============================================================
echo Version : %version%
echo Architecture : %arch%
echo Edition ID : %edition%
echo Name : %product%
if %_l% gtr 1 (
echo Display Languages : %uilangs%
echo Primary Language : %uilang%
) else (
echo Display Language : %uilang%
)
if defined LangFile if not exist "%windir%\servicing\Packages\Microsoft-Windows-Client-LanguagePack-Package~*%LangCode%*.mum" (
echo.
echo ============================================================
echo Language Pack : %LangCode% / %LangName%
echo ============================================================
echo.
choice /C 10 /N /M "Press 1 to install (%LangCode%) as primary language, or 0 to exit: "
IF ERRORLEVEL 2 (if exist "LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab" del /f /q LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab >nul&GOTO :EOF)
IF ERRORLEVEL 1 GOTO :Install
)
if %_l% gtr 1 (
echo.
echo ============================================================
echo Installed Display Languages:
for /L %%i in (1, 1, %_l%) do (
echo %%i. !UIL%%i!
)
echo.
set /p userinp= ^Enter a language number to set as primary, or 0 to exit:
if [!userinp!]==[] goto :Info
if [!userinp!]==[0] goto :eof
for /L %%i in (1, 1, %_l%) do (
if [!userinp!]==[%%i] set "LangCode=!UIL%%i!"&set "LangType=92"&set "Fallback="&set "Fallbac2="&call :!UIL%%i!&goto :Change
)
goto :Info
)
echo.
echo.
echo Press any key to exit.
pause >nul
goto :eof
:Install
set InstLP=1
cls
echo ============================================================
echo Installing %LangName% Language Pack
echo ============================================================
Dism /Online /Norestart /Add-Package /PackagePath:"%LangFile%"
if %errorlevel% neq 0 if %errorlevel% neq 3010 (set MESSAGE=ERROR: Installation failed&goto :END)
if %build% gtr 9600 if exist "%cd%\FOD\*.cab" (
echo.
echo ============================================================
echo Installing %LangCode% Language Features On Demand Packs
echo ============================================================
Dism /Online /Norestart /Add-Package /PackagePath:"%cd%\FOD"
if %errorlevel% neq 0 if %errorlevel% neq 3010 (set MESSAGE=ERROR: Installation failed&goto :END)
)
:Change
if /i "%uilang%"=="%LangCode%" (set MESSAGE=ERROR: %LangCode% is already the primary language&goto :END)
if not defined InstLP cls
echo.
echo ============================================================
echo Updating Language Settings
echo ============================================================
echo.
set "LangHexL=0000%LangHex%"
set "LangScheme=%LangHex:~2,2%%LangHex:~0,2%"
reg delete HKLM\SYSTEM\CurrentControlSet\Control\CMF\SqmData\BootLanguages /v %uilang% /f >nul
reg delete HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v NtfsAllowExtendedCharacterIn8dot3Name /f 1>nul 2>nul
if not defined InstLP (
reg add HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\%LangCode% /v LCID /t REG_DWORD /d 0x%LangHex% /f >nul
reg add HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\%LangCode% /v Type /t REG_DWORD /d 0x%LangType% /f >nul
if defined Fallback reg add HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\%LangCode% /v DefaultFallback /d %Fallback% /f >nul
if defined Fallback reg add HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\%LangCode% /v %Fallback% /t REG_MULTI_SZ /d \0 /f >nul
if defined Fallbac2 reg add HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\%LangCode% /v %Fallbac2% /t REG_MULTI_SZ /d \0 /f >nul
)
set key=HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages
FOR /F "tokens=7 delims=\" %%a IN ('reg query %key% /s /f LCID ^| find /i "UILanguages"') DO (
if /i "%%a" neq "%LangCode%" reg delete %key%\%%a /f >nul 2>&1
)
reg add HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language /v InstallLanguage /d %LangHex% /f >nul
if defined Fallback (
reg add HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language /v InstallLanguageFallback /t REG_MULTI_SZ /d %Fallback%\0%Fallbac2% /f >nul
) else (
reg delete HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language /v InstallLanguageFallback /f 1>nul 2>nul
)
reg add HKLM\SYSTEM\CurrentControlSet\Control\Nls\Locale /d %LangHexL% /f >nul
reg add "HKEY_USERS\.DEFAULT\Control Panel\Desktop" /v PreferredUILanguages /t REG_MULTI_SZ /d %LangCode% /f >nul
reg add "HKEY_USERS\.DEFAULT\Control Panel\Desktop\MuiCached" /v MachinePreferredUILanguages /t REG_MULTI_SZ /d %LangCode% /f >nul
reg add "HKEY_USERS\S-1-5-18\Control Panel\Desktop\MuiCached" /v MachinePreferredUILanguages /t REG_MULTI_SZ /d %LangCode% /f >nul
reg add "HKCU\Control Panel\Appearance" /v SchemeLangID /t REG_BINARY /d %LangScheme% /f >nul
reg add "HKCU\Control Panel\Desktop" /v PreferredUILanguages /t REG_MULTI_SZ /d %LangCode% /f >nul
reg add "HKCU\Control Panel\Desktop\MuiCached" /v MachinePreferredUILanguages /t REG_MULTI_SZ /d %LangCode% /f >nul
if %build% geq 9600 (
reg add "HKCU\Control Panel\International\User Profile" /v Languages /t REG_MULTI_SZ /d %LangCode% /f >nul
reg add "HKCU\Control Panel\International\User Profile System Backup" /v Languages /t REG_MULTI_SZ /d %LangCode% /f >nul
reg add "HKCU\Control Panel\International\User Profile System Backup\%LangCode%" /v "%LangHex%:%LangHexL%" /t REG_DWORD /d 1 /f >nul
reg add "HKCU\Control Panel\International\User Profile\%LangCode%" /v "%LangHex%:%LangHexL%" /t REG_DWORD /d 1 /f >nul
)
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\ThemeManager" /v LastUserLangID /d %LangLCID% /f >nul
bcdedit /set {current} locale %LangCode% >nul
%windir%\system32\mcbuilder.exe /s >nul
rem SCHTASKS /Change /TN "Microsoft\Windows\MUI\LPRemove" /ENABLE 1>nul 2>nul
if exist "LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab" del /f /q LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab >nul
echo.
echo ============================================================
echo Finished
echo ============================================================
echo.
echo.
echo You must restart the system to complete the display language change
echo save and close your work, then press any key to restart now...
pause >nul
SHUTDOWN /R /T 00
goto :eof
:ar-SA
set "LangName=Arabic"
set "LangLCID=1025"
set "LangHex=0401"
set "Fallback=en-US"
set "Fallbac2=fr-FR"
goto :eof
:bg-BG
set "LangName=Bulgarian"
set "LangLCID=1026"
set "LangHex=0402"
set "Fallback=en-US"
goto :eof
:cs-CZ
set "LangName=Czech"
set "LangLCID=1029"
set "LangHex=0405"
set "Fallback=en-US"
goto :eof
:da-DK
set "LangName=Danish"
set "LangLCID=1030"
set "LangHex=0406"
set "Fallback=en-US"
goto :eof
:de-DE
set "LangName=German"
set "LangLCID=1031"
set "LangHex=0407"
if %build% lss 9600 set "LangType=91"
if %build% geq 9600 set "Fallback=en-US"
goto :eof
:el-GR
set "LangName=Greek"
set "LangLCID=1032"
set "LangHex=0408"
set "Fallback=en-US"
goto :eof
:en-GB
set "LangName=English ^(United Kingdom^)"
set "LangLCID=2057"
set "LangHex=0809"
if %build% lss 9600 (set "LangType=92") else (set "LangType=112")
set "Fallback=en-US"
goto :eof
:en-US
set "LangName=English"
set "LangLCID=1033"
set "LangHex=0409"
if %build% lss 9600 (set "LangType=91") else (set "LangType=111")
goto :eof
:es-ES
set "LangName=Spanish"
set "LangLCID=3082"
set "LangHex=0C0A"
if %build% lss 9600 set "LangType=91"
if %build% geq 9600 set "Fallback=en-US"
goto :eof
:es-MX
set "LangName=Spanish ^(Mexico^)"
set "LangLCID=2058"
set "LangHex=080A"
set "LangType=112"
set "Fallback=es-ES"
goto :eof
:et-EE
set "LangName=Estonian"
set "LangLCID=1061"
set "LangHex=0425"
set "Fallback=en-US"
goto :eof
:fi-FI
set "LangName=Finnish"
set "LangLCID=1035"
set "LangHex=040B"
set "Fallback=en-US"
goto :eof
:fr-CA
set "LangName=French ^(Canada^)"
set "LangLCID=3084"
set "LangHex=0C0C"
set "LangType=112"
set "Fallback=fr-fr"
goto :eof
:fr-FR
set "LangName=French"
set "LangLCID=1036"
set "LangHex=040C"
if %build% lss 9600 set "LangType=91"
if %build% geq 9600 set "Fallback=en-US"
goto :eof
:he-il
set "LangName=Hebrew"
set "LangLCID=1037"
set "LangHex=040D"
set "Fallback=en-US"
goto :eof
:hr-HR
set "LangName=Croatian"
set "LangLCID=1050"
set "LangHex=041A"
set "Fallback=en-US"
goto :eof
:hu-HU
set "LangName=Hungarian"
set "LangLCID=1038"
set "LangHex=040E"
set "Fallback=en-US"
goto :eof
:it-IT
set "LangName=Italian"
set "LangLCID=1040"
set "LangHex=0410"
if %build% lss 9600 set "LangType=91"
if %build% geq 9600 set "Fallback=en-US"
goto :eof
:ja-JP
set "LangName=Japanese"
set "LangLCID=1041"
set "LangHex=0411"
if %build% lss 9600 set "LangType=91"
if %build% geq 9600 set "Fallback=en-US"
goto :eof
:ko-KR
set "LangName=Korean"
set "LangLCID=1042"
set "LangHex=0412"
set "Fallback=en-US"
goto :eof
:lt-LT
set "LangName=Lithuanian"
set "LangLCID=1063"
set "LangHex=0427"
set "Fallback=en-US"
goto :eof
:lv-LV
set "LangName=Latvian"
set "LangLCID=1062"
set "LangHex=0426"
set "Fallback=en-US"
goto :eof
:nb-NO
set "LangName=Norwegian ^(Bokmal^)"
set "LangLCID=1044"
set "LangHex=0414"
set "Fallback=en-US"
goto :eof
:nl-NL
set "LangName=Dutch"
set "LangLCID=1043"
set "LangHex=0413"
if %build% lss 9600 set "LangType=91"
if %build% geq 9600 set "Fallback=en-US"
goto :eof
:pl-PL
set "LangName=Polish"
set "LangLCID=1045"
set "LangHex=0415"
set "Fallback=en-US"
goto :eof
:pt-BR
set "LangName=Portuguese ^(Brazil^)"
set "LangLCID=1046"
set "LangHex=0416"
set "LangType=112"
set "Fallback=en-US"
goto :eof
:pt-PT
set "LangName=Portuguese ^(Portugal^)"
set "LangLCID=2070"
set "LangHex=0816"
set "LangType=112"
set "Fallback=en-US"
goto :eof
:ro-RO
set "LangName=Romanian"
set "LangLCID=1048"
set "LangHex=0418"
set "Fallback=en-US"
goto :eof
:ru-RU
set "LangName=Russian"
set "LangLCID=1049"
set "LangHex=0419"
set "Fallback=en-US"
goto :eof
:sk-SK
set "LangName=Slovak"
set "LangLCID=1051"
set "LangHex=041B"
set "Fallback=en-US"
goto :eof
:sl-SI
set "LangName=Slovenian"
set "LangLCID=1060"
set "LangHex=0424"
set "Fallback=en-US"
goto :eof
:sr-Latn-CS
set "LangName=Serbian ^(Latin^)"
set "LangLCID=2074"
set "LangHex=081A"
set "Fallback=en-US"
goto :eof
:sr-Latn-RS
set "LangName=Serbian ^(Latin^)"
set "LangLCID=9242"
set "LangHex=241A"
set "Fallback=en-US"
goto :eof
:sv-SE
set "LangName=Swedish"
set "LangLCID=1053"
set "LangHex=041D"
set "Fallback=en-US"
goto :eof
:th-TH
set "LangName=Thai"
set "LangLCID=1054"
set "LangHex=041E"
set "Fallback=en-US"
goto :eof
:tr-TR
set "LangName=Turkish"
set "LangLCID=1055"
set "LangHex=041F"
set "Fallback=en-US"
goto :eof
:uk-UA
set "LangName=Ukrainian"
set "LangLCID=1058"
set "LangHex=0422"
set "Fallback=en-US"
goto :eof
:zh-CN
set "LangName=Chinese ^(Simplified^)"
set "LangLCID=2052"
set "LangHex=0804"
set "Fallback=en-US"
goto :eof
:zh-HK
set "LangName=Chinese ^(Hong Kong SAR^)"
set "LangLCID=3076"
set "LangHex=0C04"
set "Fallback=zh-TW"
set "Fallbac2=en-US"
goto :eof
:zh-TW
set "LangName=Chinese ^(Taiwan^)"
set "LangLCID=1028"
set "LangHex=0404"
set "LangType=112"
set "Fallback=en-US"
goto :eof
:END
if exist "LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab" del /f /q LangPack\%build%_%PROCESSOR_ARCHITECTURE%.cab >nul
echo.
echo ============================================================
echo %MESSAGE%
echo ============================================================
echo.
echo Press any Key to Exit.
pause >nul
goto :eof