Wednesday, June 17, 2009

MultiLanguage Patch - MSP


If you are thinking about some command for MSI installer to do so, there is'nt any. What we are going to implement is a Hack where we can deploy the langauage transforms before applying the patch.

How we are going to do this is
1) Get MST files from the Installshield build output folder
2) Create a Package using NullSoft Installer( its easy)
3) Write code in nullsoft to replace the MST file locally
4) Extract the update.exe or MSP and run

Original MST file is stored in C:\WINDOWS\Installer\{PROD_CODE}\1031.MST, you can find out the path by reading HKLM\SOFTWARE\Classes\Installer\Products\MY.PROD.GUID and value of transforms key. Now you can go and replace this file and run the patch. Below is the code for doing this. Use NSIS compiler to compile it.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_VERSION "3.3"
!define PRODUCT_PUBLISHER "ItsMe"
!define PRODUCT_WEB_SITE "http://www.MySite.com"

; MUI 1.67 compatible ------
!include "MUI.nsh"


!define MUI_ICON "Developer.ico"

;
; Language files
!insertmacro MUI_LANGUAGE "English"



SetCompress auto
OutFile "Patch.exe"
Function .onInit

SetSilent silent

FunctionEnd


Section "MainSection" SEC01
SetOutPath "$tempdir"
SetOverwrite ifnewer
File "D:\Build Output\Patch\Update.exe"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1031.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1032.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1033.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1034.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1036.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1041.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1040.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1043.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1046.mst"

ReadRegStr $0 HKLM "SOFTWARE\Classes\Installer\Products\MY.PROD.GUID" "transforms"

; remove
StrCpy $1 $0 "" -8

Rename $0 "$0.bak"
CopyFiles $tempdir\$1 $0

exec "$tempdir\Update.exe"
SectionEnd

Section -AdditionalIcons
SectionEnd

Section -Post
SectionEnd

No comments: