How to add LangPacks to non-ultimate/enterprise Windows 7? Possible?

Discussion in 'Windows 7' started by dvda2k, Jan 31, 2011.

  1. dvda2k

    dvda2k MDL Novice

    Jul 23, 2008
    12
    0
    0
    #1 dvda2k, Jan 31, 2011
    Last edited by a moderator: Apr 20, 2017
    My goal is to build a home/professional edition of windows 7 w/SP1 which offers the option to choose between English/Chinese during Windows Welcome, based on the leaked English ISO and Chinese language packs.

    I saw the following on MSDN suggesting it is possible:

    So I basically (1) mount the install.wim, (2) add the lp.cab, (3) update lang.ini, (4) unmount and commit. Repeat for all 5 indexes (x86 ISO has 5 indexes, x64 has 4 indexes). And then do the same thing to boot.wim (index 2 only, with WinPE LangPacks) and delete ei.cfg. The codes are:

    Code:
    dism /mount-wim /wimfile:windows\sources\install.wim /name:"Windows 7 Professional" /mountdir:mount
    dism /image:mount /add-package /packages-path:lp.cab
    dism /image:mount /gen-langini /distribution:windows
    dism /unmount-wim /mountdir:mount /commit
    the new lang.ini under ISO:\sources\ and in boot.wim look like this:

    Code:
    [Available UI Languages]
    en-US = 3
    zh-CN = 2
    
    [Fallback Languages]
    en-US = en-us
    The newly built ISO boots fine in Virtual PC, and I can choose language for setup and the windows-to-install. But the problem is if I choose to install home/pro in the newly added language (Chinese), after "expanding files" goes to 100%, I always get this 0x80000001 error, saying "Windows could not set the offline locale information":

    VPC.jpg

    If I choose English version, the setup can be done, but NO language selection dialog prompted during OOBE. And in the new system "dism /online /get-packages" shows no Chinese LangPacks installed.
    If I choose Ulimate in either English or Chinese, everthing works pefect. The Windows get installed and I can switch between two languages later on.

    I've tried a couple of combinations with /set-allintl /set-skuintldefaults and /gen-langini, but with no luck.

    Any suggestion guys?
     
  2. tcntad

    tcntad MDL Guru

    Oct 26, 2009
    4,081
    1,298
    150
    #2 tcntad, Jan 31, 2011
    Last edited by a moderator: Apr 20, 2017
    Fixed
    Code:
    dism /mount-wim /wimfile:DVD\Sources\install.wim /Index:4 /mountdir:mount
    dism /image:mount /add-package /packagepath:lp.cab
    dism /image:mount /gen-langini /distribution:windows
    dism /unmount-wim /mountdir:mount /commit
    
     
  3. dvda2k

    dvda2k MDL Novice

    Jul 23, 2008
    12
    0
    0
    #3 dvda2k, Jan 31, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    tcntad, thanks for the correction. But it's my typo here, I did everythings right with my automatic batch.

    Still waiting for answers.

    By the way, does anyone know any ISO having this "select language during OOBE" feature that I can download to have a look.
     
  4. tcntad

    tcntad MDL Guru

    Oct 26, 2009
    4,081
    1,298
    150
    #4 tcntad, Jan 31, 2011
    Last edited by a moderator: Apr 20, 2017
    Well I have one but its not uploaded anywhere and its 6 GB with my apps and windows updates (.msu) until november last year :p

    Hm I see now in my own script that its
    Code:
    DISM.exe /Mount-Wim /WimFile:DVD\Sources\Install.wim /Index:2 /MountDirMount
    DISM.exe /Image:Mount /Add-Package /Packagepath:\LP.cab
    DISM.exe /Image:Mount /Gen-LangINI /Distribution:DVD
    DISM.exe /UnMount-Wim /MountDir:Mount /Commit
    
    You seem to be using genlangini for windows and not dvd as I do. Works great for me:)
     
  5. dvda2k

    dvda2k MDL Novice

    Jul 23, 2008
    12
    0
    0
    DVD or Windows, or called distribution on MSDN, as long as it's the folder you extract all the files from the ISO.

    It's quite weird. If the same script works for you.

    My actual slipstreaming script is quite complex, so maybe something gets wrong without notice. I'll try to trim down other things see what result I get.
     
  6. tcntad

    tcntad MDL Guru

    Oct 26, 2009
    4,081
    1,298
    150
    How does your whole script look like? Just interested :p

    Mine is quiet simple actucally but it does the job.
     
  7. dvda2k

    dvda2k MDL Novice

    Jul 23, 2008
    12
    0
    0
    #7 dvda2k, Jan 31, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    The script will:

    1) clone itself (Run.cmd), then call the clone by "Temp\RunTemp.cmd >log.log 2&1>". This is done in purpose of logging.
    2) the clone will check whether it is elevated and the existence of lang packs.
    3) the clone will extract msu/cab from IE9 installer, and put the msu/cab into Extra folder
    4) all msu/cab in Extra folder will be added alongside with extracted IE9.
    5) the clone will add lang pack to install.wim, boot.wim, and winre.wim, you can choose which install.wim index to modify with predefined variables.
    6) pass back to the original script, and delete all temp files
    7) build an ISO when everything is done.
    8) the number of error occured during excution is stored and displayed in the end. Time for each phase is also displayed.

    So in couple of hours, I get a new iso and detailed logs.

    The echo and comments are in Chinese, but if anyone interested I can make a English one.

    Code:
    :: 本批处理首先自我复制一个副本到 Temp 子目录下
    :: 随后调用副本的 Main 子程序,执行集成任务
    :: 完成后,转回本体,进行临时文件的清理并显示执行结果
    :: 创建副本的目的是为了记录完整的日志
    
    @IF %~nx0==RunTemp.cmd GOTO :Main
    @CLS
    @SET WorkPath=%~dp0
    @SET WorkPath=%WorkPath:~0,-1%
    @SET Temp=%WorkPath%\Temp
    @SET Tools=%WorkPath%\Tools
    @SET Windows=%WorkPath%\Windows
    @SET LangPacks=%WorkPath%\LangPacks
    @SET LangPacksWinPE=%WorkPath%\LangPacksWinPE
    @SET Extra=%WorkPath%\Extra
    @SET IE9Exe=%Extra%\IE9-Windows7-x86-enu.exe
    :: ========================================
    :: 定义需要集成的版本索引。分别为:1 简易版、2 家庭版普通版、3 家庭高级版、4 专业版、5 旗舰版。使用空格分隔如:@SET IdxSet=1 4 5
    @SET IdxSet=1 2 3 4 5
    :: 新安装的语言
    @SET LangToAdd=zh-CN
    @SET ModifyInstallWim=1
    @SET ModifyWinREWim=1
    @SET ModifyBootWim=1
    @SET CompressInstallWim=1
    :: 是否安装语言包
    @SET AddLangPacks=1
    :: 是否将新安装的语言设为默认语言
    @SET ChangeDefLang=1
    :: 是否安装自定义包
    @SET AddExtra=1
    :: 是否允许选择所有可用版本
    @SET EnableEditionSelect=1
    :: 是否生成 ISO
    @SET BuildISO=1
    :: 初始化错误计数器
    @SET ErrCnt=0
    :: ========================================
    @MD "%Temp%" >NUL 2>&1
    @MD "%Temp%\boot_wim" >NUL 2>&1
    @MD "%Temp%\install_wim" >NUL 2>&1
    @MD "%Temp%\winre_wim" >NUL 2>&1
    :: ========================================
    :: 自我复制到临时文件夹,调用新建立的副本 RunTemp.cmd,并记录日志
    @COPY /Y %0 "%Temp%\RunTemp.cmd" >NUL 2>&1
    @CALL "%Temp%\RunTemp.cmd" >"%WorkPath%\Log.log" 2>&1
    :: ========================================
    :: 副本执行完毕,转回本体
    @RD /S /Q "%Temp%" >>"%WorkPath%\Log.log" 2>&1
    @IF EXIST "%IE9Pack%" DEL "%IE9Pack%" >>"%WorkPath%\Log.log" 2>&1
    @ECHO. >>"%WorkPath%\Log.log" 2>&1
    @IF "%ErrMsg%"=="" SET ErrMsg=执行完毕,期间发生了%ErrCnt%个错误。查看 Log.log 获得更详细信息
    @ECHO %ErrMsg%
    @ECHO %CD%^>%ErrMsg% >>"%WorkPath%\Log.log" 2>&1
    @ECHO.
    @SET /P txt=批处理将退出,<NUL
    @PAUSE
    @GOTO :EOF
    :: ================================================================================
    
    
    
    :Main
    @TITLE Windows 7 集成 >CON
    @ECHO. >CON
    @ECHO “Windows 7 集成”批处理 1.0>CON
    @ECHO. >CON
    @ECHO ================================================================================ >CON
    :: ================================================================================
    :: 检查文件与目录结构
    @IF "%ModifyInstallWim%"=="1" (IF NOT EXIST "%Windows%\sources\install.wim" SET ErrMsg=严重错误:未能找到 %Windows%\sources\install.wim)
    @IF "%ModifyBootWim%"=="1" (IF NOT EXIST "%Windows%\sources\boot.wim" SET ErrMsg=严重错误:未能找到 %Windows%\sources\boot.wim)
    @IF "%ModifyBootWim%"=="1" (IF NOT EXIST "%LangPacksWinPE%\LP_%LangToAdd%.cab" SET ErrMsg=严重错误:未能找到 Windows PE 语言包 %LangPacksWinPE%\LP_%LangToAdd%.cab)
    @IF "%ModifyBootWim%"=="1" (IF NOT EXIST "%LangPacksWinPE%\WINPE-*.cab" SET ErrMsg=严重错误:未能找到 Windows PE 语言包)
    @IF "%AddLangPacks%"=="1" (IF NOT EXIST "%LangPacks%\lp.cab" SET ErrMsg=严重错误:未能找到 Windows 7 语言包 %LangPacks%\lp.cab)
    @IF "%AddExtra%"=="1" (IF NOT EXIST "%Extra%\*.msu" (IF NOT EXIST "%Extra%\*.cab" SET ErrMsg=严重错误:未能找到 .cab/.msu 格式自定义安装包))
    :: 检查权限
    @ECHO.
    @SET /P txt=%CD%^>检查是否具有管理员权限. . . <NUL
    @ECHO 这是由“Windows 7 整合”批处理生成的临时测试文件。本文件可以删除。>"%SystemDrive%\ElevationTest.log" 2>&1
    @IF NOT EXIST "%SystemDrive%\ElevationTest.log" (
    SET ErrMsg=严重错误:权限不够。请右键单击,选择“以管理员身份运行”) ELSE (
    ECHO 检查通过
    DEL "%SystemDrive%\ElevationTest.log")
    :: 如果有严重错误,结束 RunTemp.cmd,转回 Run.cmd
    @IF NOT "%ErrMsg%"=="" GOTO :EOF
    :: ================================================================================
    
    :: ================================================================================
    @IF "%ModifyInstallWim%"=="0" GOTO :Skip_ModifyInstallWim
    @FOR %%i IN (%IdxSet%) DO @CALL :SubModifyInstallWim %%i
    :Skip_ModifyInstallWim
    :: ================================================================================
    
    :: ================================================================================
    @IF "%CompressInstallWim%"=="0" GOTO :Skip_CompressInstallWim
    ECHO %TIME:~0,8%  压缩 Install.wim 映像 >CON
    RENAME "%Windows%\sources\install.wim" install.wim.bak
    @CALL :ErrCnt 0
    "%Tools%\imagex.exe" /EXPORT "%Windows%\sources\install.wim.bak" * "%Windows%\sources\install.wim" /CHECK /COMPRESS maximum
    @CALL :ErrCnt 0
    IF EXIST "%Windows%\sources\install.wim" DEL "%Windows%\sources\install.wim.bak"
    @CALL :ErrCnt 0
    @ECHO. >CON
    :Skip_CompressInstallWim
    :: ================================================================================
    
    :: ================================================================================
    @IF "%ModifyBootWim%"=="0" GOTO :Skip_ModifyBootWim
    @IF "%AddLangPacks%"=="0" GOTO :Skip_ModifyBootWim
    ECHO %TIME:~0,8%  Boot.wim    - 加载映像 >CON
    DISM /Mount-Wim /WimFile:"%Windows%\sources\boot.wim" /Index:2 /MountDir:"%Temp%\boot_wim"
    @CALL :ErrCnt 0
    :: ========================================
    ECHO %TIME:~0,8%              - 添加语言包 >CON
    DISM /Image:"%Temp%\boot_wim" /Add-Package /PackagePath:"%LangPacksWinPE%"
    @CALL :ErrCnt 0
    @IF "%ChangeDefLang%"=="1" (
    ECHO %TIME:~0,8%              - 设置默认语言为 %LangToAdd% >CON
    DISM /Image:"%Temp%\boot_wim" /Set-SKUIntlDefaults:%LangToAdd%
    @CALL :ErrCnt 0)
    ECHO %TIME:~0,8%              - 更新语言配置文件
    DISM /Image:"%Temp%\boot_wim" /Gen-LangINI /Distribution:"%Temp%\boot_wim"
    @CALL :ErrCnt 0
    :: ========================================
    ECHO %TIME:~0,8%              - 添加用户协议 >CON
    XCOPY "%Temp%\boot_wim\sources\%LangToAdd%" "%Windows%\sources\%LangToAdd%" /QICHEKRY
    @CALL :ErrCnt 0
    XCOPY "%Temp%\boot_wim\sources\license\%LangToAdd%" "%Windows%\sources\license\%LangToAdd%" /QICHEKRY
    @CALL :ErrCnt 0
    :: ========================================
    ECHO %TIME:~0,8%              - 卸载映像 >CON
    DISM /Unmount-Wim /MountDir:"%Temp%\boot_wim" /Commit
    @CALL :ErrCnt 0
    @ECHO. >CON
    :Skip_ModifyBootWim
    :: ================================================================================
    
    :: ================================================================================
    @IF "%EnableEditionSelect%"=="0" GOTO :Skip_EnableEditionSelect
    ECHO %TIME:~0,8%  删除 ei.cfg 以允许版本选择 >CON
    DEL "%Windows%\sources\ei.cfg"
    @CALL :ErrCnt 0
    @ECHO. >CON
    :Skip_EnableEditionSelect
    :: ================================================================================
    
    :: ================================================================================
    @IF "%BuildISO%"=="0" GOTO :Skip_BuildISO
    ECHO %TIME:~0,8%  生成 ISO 文件 >CON
    @ECHO boot\bcd >"%Temp%\bootorder.txt"
    @ECHO boot\boot.sdi >>"%Temp%\bootorder.txt"
    @ECHO boot\bootfix.bin >>"%Temp%\bootorder.txt"
    @ECHO boot\bootsect.exe >>"%Temp%\bootorder.txt"
    @ECHO boot\etfsboot.com >>"%Temp%\bootorder.txt"
    @ECHO boot\memtest.efi >>"%Temp%\bootorder.txt"
    @ECHO boot\memtest.exe >>"%Temp%\bootorder.txt"
    @ECHO boot\en-us\bootsect.exe.mui >>"%Temp%\bootorder.txt"
    @ECHO boot\fonts\chs_boot.ttf >>"%Temp%\bootorder.txt"
    @ECHO boot\fonts\cht_boot.ttf >>"%Temp%\bootorder.txt"
    @ECHO boot\fonts\jpn_boot.ttf >>"%Temp%\bootorder.txt"
    @ECHO boot\fonts\kor_boot.ttf >>"%Temp%\bootorder.txt"
    @ECHO boot\fonts\wgl4_boot.ttf >>"%Temp%\bootorder.txt"
    @ECHO sources\boot.wim >>"%Temp%\bootorder.txt"
    "%Tools%\oscdimg.exe" -m -n -yo"%Temp%\bootorder.txt" -b"%Tools%\etfsboot.com" "%Windows%" "%WorkPath%\Windows.iso"
    @ECHO. >CON
    :Skip_BuildISO
    :: ================================================================================
    
    @ECHO ================================================================================ >CON
    @GOTO :EOF
    :: ================================================================================
    
    
    
    :: 子程序
    :SubModifyInstallWim
    ECHO %TIME:~0,8%  Install.wim - 加载映像的第%1个索引 >CON
    DISM /Mount-Wim /WimFile:"%Windows%\sources\install.wim" /Index:%1 /MountDir:"%Temp%\install_wim"
    @CALL :ErrCnt 0
    :: ========================================
    @IF "%AddLangPacks%"=="0" GOTO :Skip_AddLangPacks
    ECHO %TIME:~0,8%              - 添加语言包 >CON
    DISM /Image:"%Temp%\install_wim" /Add-Package /PackagePath:"%LangPacks%"
    @CALL :ErrCnt 0
    IF "%ChangeDefLang%"=="1" (
    ECHO %TIME:~0,8%              - 设置默认语言为 %LangToAdd% >CON
    DISM /Image:"%Temp%\install_wim" /Set-SKUIntlDefaults:%LangToAdd%
    @CALL :ErrCnt 0)
    ECHO %TIME:~0,8%              - 更新语言配置文件 >CON
    DISM /Image:"%Temp%\install_wim" /Gen-LangINI /Distribution:"%Windows%"
    @CALL :ErrCnt 0
    :Skip_AddLangPacks
    :: ========================================
    @IF "%AddExtra%"=="0" GOTO :SKIP_IE9Prep
    @IF NOT EXIST "%IE9Exe%" GOTO :SKIP_IE9Prep
    @IF "%IE9Prep_Done%"=="1" GOTO :SKIP_IE9Prep
    ECHO %TIME:~0,8%              - 准备 IE9 安装包>CON
    "%IE9Exe%" /x:"%Temp%\IE9"
    @CALL :ErrCnt 50002
    IF EXIST "%Temp%\IE9\IE9-Win7.cab" (COPY /Y "%Temp%\IE9\IE9-Win7.cab" "%Extra%" & SET IE9Pack=%Extra%\IE9-Win7.cab)
    IF EXIST "%Temp%\IE9\IE9-Win7.msu" (COPY /Y "%Temp%\IE9\IE9-Win7.msu" "%Extra%" & SET IE9Pack=%Extra%\IE9-Win7.msu)
    @CALL :ErrCnt 0
    @SET IE9Prep_Done=1
    :SKIP_IE9Prep
    :: ========================================
    :: 用 CALL 调用子程序。避免了使用 SETLOCAL EnableDelayedExpansion 后 ErrCnt 成为局部变量,造成的计数错误
    @IF "%AddExtra%"=="0" GOTO :Skip_Extra
    @FOR /R "%Extra%" %%f IN (*.msu,*.cab) DO CALL :SubAddExtra "%%f"
    :Skip_Extra
    :: ========================================
    @IF "%ModifyWinREWim%"=="0" GOTO :Skip_ModifyWinREWim
    @IF "%AddLangPacks%"=="0" GOTO :Skip_ModifyWinREWim
    IF "%WinREModified%"=="1" (COPY /Y "%Temp%\winRE.wim" "%Temp%\install_wim\Windows\System32\Recovery" & GOTO :Skip_ModifyWinREWim)
    ECHO %TIME:~0,8%              - 加载 WinRE.wim 映像 >CON
    DISM /Mount-Wim /WimFile:"%Temp%\install_wim\Windows\System32\Recovery\winRE.wim" /Index:1 /MountDir:"%Temp%\winre_wim"
    @CALL :ErrCnt 0
    ECHO %TIME:~0,8%              - 添加 WinRE.wim 语言包 >CON
    DISM /Image:"%Temp%\winre_wim" /Add-Package /PackagePath:"%LangPacksWinPE%"
    @CALL :ErrCnt 0
    @IF "%ChangeDefLang%"=="1" (
    ECHO %TIME:~0,8%              - 设置 WinRE.wim 默认语言为 %LangToAdd% >CON
    DISM /Image:"%Temp%\winre_wim" /Set-SKUIntlDefaults:%LangToAdd%
    @CALL :ErrCnt 0)
    ECHO %TIME:~0,8%              - 更新 WinRE.wim 语言配置文件
    DISM /Image:"%Temp%\winre_wim" /Gen-LangINI /Distribution:"%Temp%\winre_wim"
    @CALL :ErrCnt 0
    ECHO %TIME:~0,8%              - 卸载 WinRE.wim 映像 >CON
    DISM /Unmount-Wim /MountDir:"%Temp%\winre_wim" /Commit
    COPY "%Temp%\install_wim\Windows\System32\Recovery\winRE.wim" "%Temp%"
    SET WinREModified=1
    @CALL :ErrCnt 0
    :Skip_ModifyWinREWim
    :: ========================================
    ECHO %TIME:~0,8%              - 卸载映像 >CON
    DISM /Unmount-Wim /MountDir:"%Temp%\install_wim" /Commit
    @CALL :ErrCnt 0
    :: ========================================
    @ECHO. >CON
    @GOTO :EOF
    :: ================================================================================
    
    
    :: ================================================================================
    :SubAddExtra
    ECHO %TIME:~0,8%              - 添加自定义安装包:%~nx1 >CON
    DISM /Image:"%Temp%\install_wim" /Add-Package /PackagePath:"%1"
    @CALL :ErrCnt 0
    @GOTO :EOF
    :: ================================================================================
    
    
    :: ================================================================================
    :ErrCnt
    @IF NOT "%ERRORLEVEL%"=="%1" (SET /A ErrCnt+=1 & ECHO. & ECHO ======== 发生错误,错误代码:%ERRORLEVEL% ========)
    @GOTO :EOF
    :: ================================================================================
    
    To make it run, your need to make your folders look like this, other wise you'll get "严重错误:... ... ..." error messages:

    Extra
    LangPacks
    LangPacksWinPE
    Tools
    Windows
    Run.cmd

    The lang packs folders are pretty self explained. Put all lang packs under respective folders with its original name, like lp.cab, LP_??-??.cab, WINPE-*.cab.
    Under tools, you need to have oscdimg.exe, ETFSBOOT.com, both from Windows AIK/OPK. ETFSBOOT.com contains the bootable sector of windows setup DVD.
     
  8. tcntad

    tcntad MDL Guru

    Oct 26, 2009
    4,081
    1,298
    150
    Sure! My gf can translate though, i think :p
     
  9. Kouryu

    Kouryu MDL Senior Member

    Jan 19, 2011
    408
    111
    10
  10. dvda2k

    dvda2k MDL Novice

    Jul 23, 2008
    12
    0
    0
    Yes I did search and read the post you listed. I did understand langpacks can't be added to non-ult/ent windows 7 once it is installed.

    But my problem is the 0x8000001 "Windows could not set the offline locale information" error during windows installing. I saw somebody in another MDL multilanguale tutorial post reporting the same problem, but his solution is to avoid serving edtions other than ulimate/enterprise.
     
  11. tcntad

    tcntad MDL Guru

    Oct 26, 2009
    4,081
    1,298
    150
    Weird:/ and yes you can change language using dism once windows is installed;)

    Add language pack
    Edit bcdedit current locale
    edit bcdboot / locale

    remove keys in registry:)
     
  12. Kouryu

    Kouryu MDL Senior Member

    Jan 19, 2011
    408
    111
    10
    you should try using the script ttmax posted or integrate using my method... either way works fine and no one ever had problems
    then you need to remove any other complications... get rid of IE9, it's beta and has no reason to be part of a windows install disc anyway
     
  13. dvda2k

    dvda2k MDL Novice

    Jul 23, 2008
    12
    0
    0
    Thank you guys. I've nailed down the bug in my script where I used "dism /mount-wim /wimfile /name" but should use "dism /mount-wim /wimfile /index". So everything works perfect now. Revise had been down to the script posted in #7.

    tcntad, Kouryu, thank you!