Sunday, July 03, 2011

Windows 7 Language Pack Installation and Un-Installation on 32 bit and 64 bit Machines

Recently I had to package Window 7 MUI for around 13 languages, both for 32 bit and 64 bit machines. I could not get any complete documentation for Installing, Un-Installing and making it work with the Deployment tool.

I thought to write this article so it reduces the work of people who still have to make Language packs as a package.

Windows 7 Language Packs come in a DVD and generally have a cab file called, lp.cab for all the languages in their respective folders.

Following are the main command lines to be used while installing and Un-installing the Language Packs:



Installation:

dism /online /add-package /quiet /norestart /packagepath:lp.cab

and

Un-Installation:

dism /online /remove-package /quiet /norestart /packagepath:lp.cab



The lp.cab file can be copied to a temp location by your MSI and then a setup.bat file would be required to run the above command line.

I had copied lp.cab, setup.bat,setup.vbs, uninstall.bat and uninstall.vbs to “%windir%\temp\” folder.



Here are the uses of all these files and how they are related in MSI.



Lp.cab: This is the basic installer cab file of the language pack which you can get through the source or DVD
Setup.bat: This is the batch file to install the language pack as per the above command line.
Setup.vbs: This .vbs file locally calls the setup.bat file, as if you are deploying from Deployment tool/network location then the batch file throws an error as it cannot resolve the UNC paths.
Uninstall.bat: This is the batch file to un-install the language pack using the above mentioned command line.
Uninstall.vbs: This .vbs file locally calls the uninstall.bat file, as if you are deploying from Deployment tool/network location then the batch file throws an error as it cannot resolve the UNC paths. Also this when wrapped in MSI, you can un-install the package from Add/Remove Programs and the language pack can be un-installed.


After creating and adding these files to a temporary location, you can add 2 custom Actions, one for install and other for un-install to run the vbs files from installed filed.

The Installation Custom Action can be placed just before InstallFinalize with condition as NOT REMOVE, and the Un-Installation Custom Action can be placed just after InstallInitialize with condition as REMOVE.



Now since you have read this from Packaging perspective this goes well for both 32 bit and 64 bit machines. But if now you try to install this MSI from Deployment tool or any other deployment tool which uses system account to run, you will face an issue with the 64 bit machines.

The reason for not working in 64-bit machines is that when the MSI is run in system account all the scripts/batch file are run through cmd.exe which is in c:\windows\syswow64 folder. This does not work for dism command line and I had to use a workaround for this issue.

The work around is that you need to run the dism command from %windir%\Sysnative.

This works fine and I have inserted the below line in the batch file for both install and un-install before running the dism installation command:

cd %windir%\sysnative



So the batch file looks like:

Install:

@echo off

cd %windir%\sysnative

dism /online /add-package /quiet /norestart /packagepath:%windir%\temp\Microsoft_Win7MUI_Arabicx64 \lp.cab



Uninstall:

@echo off

cd %windir%\sysnative

dism /online /remove-package /quiet /norestart /packagepath:%windir%\temp\Microsoft_Win7MUI_Arabicx64 \lp.cab





I hope all this information will be helpful for you to create the language packs. It took me a week to figure these things out. Hope you will not face this difficulty.

No comments: