I think this would be the right place to ask.. I have Windows 7 AIO with 3 languages but im only using English.. So after an install of windows 7 ultimate i have 2 extra languages i really dont need.. The languages are there beacuse other might need swedish language and my gf wants chinese language.. I want to run the script manually after install if i want I guess i have to identify the installed language and somehow remove the other two.. But how can i do that? Edit: Nice with a scripting subforum!
@timesurfer I think it would be a good idea to have individual threads for each problem, so a solution can be posted for it and later discussing and clarifying doubts about the solution. Everything in a single thread makes it difficult in the later stage of the thread. For example take the Windows Loader thread or Windows Repository thread, how many times have you given the same answer over and over again even though the answer lies in the first post.
Run the following code in command prompt to make a list of installed languages. Code: for /f "tokens=2,* delims=:" %A in ('"dism /Online /Get-Packages|find "LanguagePack""') do @for /f "tokens=4 delims=~" %a in ("%A") do echo %a Code: wmic OS get OSLanguage This will give the Installed OS language in LCID form. The next step would be to determine a reliable way of getting the system default language.
Check this code in VM before trying it out on a real machine. Run the script as Administrator. Code: @echo off setlocal enabledelayedexpansion for /f "tokens=2 delims==" %%A in ('wmic os get oslanguage /format:list') do ( call :dec2hex %%A ) for /f %%A in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages"') do ( for /f "tokens=3" %%a in ('reg query "%%A" /v LCID') do ( if %%a==%lcid% ( for /f "tokens=7 delims=\" %%b in ("%%A") do ( set locale=%%b ) ) ) ) for /f "tokens=2,* delims=:" %%A in ('"dism /Online /Get-Packages|find "LanguagePack""') do ( for /f "tokens=4 delims=~" %%a in ("%%A") do ( if NOT %locale%==%%a ( set pkg=%%A set pkg=!pkg: =! dism /online /Remove-Package /PackageName:!pkg! ) ) ) pause exit :dec2hex setlocal enabledelayedexpansion set /a num=%1 set digits=0123456789ABCDEF set ans= :loop set /a rmd=%num% %% 16 set /a num /= 16 set ans=!digits:~%rmd%,1!%ans% if NOT %num%==0 goto loop endlocal & set lcid=0x%ans% exit /b First for gets the lcid Second for convert lcid to locale name Third for removes language packs except the current language.
OK lets do it one step at a time Code: wmic OS get OSLanguage reg query "HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages dism /Online /Get-Intl Post the output of the above commands
Works fine Code: D:\>wmic OS get OSLanguage OSLanguage 1033 D:\>reg query "HKLM\SYSTEM\CurrentControlSet\Control\MUI\UILanguages HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-US HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\zh-TW D:\>dism /Online /Get-Intl Deployment Image Servicing and Management tool Version: 6.1.7600.16385 Image Version: 6.1.7600.16385 Reporting online international settings. Default system UI language : en-US System locale : sv-SE Default time zone : W. Europe Standard Time Active keyboard(s) : 041d:0000041d, 0409:00000409 Keyboard layered driver : PC/AT Enhanced Keyboard (101/102-Key) Installed language(s): en-US Type : Fully localized language. Installed language(s): zh-TW Type : Partially localized language, MUI type. Fallback Languages en-US The operation completed successfully. I just had to add pause in the script otherwise the window would shutdown immediately.
OK, your default language is english and you have a chinese as additional language Post the output of the following command. Just open a command prompt as Administrator and copy paste the code and hit enter. Code: dism /Online /Get-Packages|find "LanguagePack" This will list the package names of the installed language packs.
Took some time but here it is.. Probably beacuseof my harddrive.. really need a new one!. Code: Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Pet>dism /Online /Get-Packages|find "LanguagePack" Package Identity : Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e3 5~amd64~en-US~6.1.7600.16385 Package Identity : Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e3 5~amd64~zh-TW~6.1.7600.16385
What the script basically does is gets the LCID from wmic output and stroes it in LCID variable in hexadecimal form. Next it iterates through the MUI\UILanguages key in HKLM\SYSTEM\CurrentControlSet\Control and matches the LCID value with the subkeys. If a match is successful, it stores the key name say en-us in the locale variable. Now the dism command is run to find packages with LanguagePack and checks if the locale of the language pack matches with the system locale. If it does not match it issues the RemovePackage command of dism to remove the package. Add pause to the script after each for and see where it quits abruptly.
Tried both the small commands and now the big one. sofar sogood. Edit: Deleting chinese traditional (zh-tw) language pack worked fine, even asked me to restart I will try this on my laptop once again.. Edit2: Still doesnt work, ran the script with the commands to find out languages (called "bla.cmd") that worked just fine But when i ran "lang.cmd" with the code from posts above it did the same, just shut down.