Add installation path in registry

When we will create installer of any application by default it will not write the installation

path (InstallLocation) in the registry when we will install that installer. For this we have to

insert the InstallLocation in the CustomAction table of msi database.

Step 1: and we have saved it at c:\app folder.

Create a vb scrip file save it. Suppose its name is SetInstallLocation.vbs

Vb script code is as follow:

Option Explicit

Dim InstallerObj

Set InstallerObj = Wscript.CreateObject("WindowsInstaller.Installer")

Dim DbObj

DbObj = Wscript.Arguments(0)

Dim MsiDbObj

Set MsiDbObj = InstallerObj.OpenDatabase(DbObj,1)

Dim QueryStr,CommandObj

QueryStr = "INSERT INTO `CustomAction` (`Action`, `Type`, `Source`, `Target`) VALUES ('InstallLocation', '51', 'ARPINSTALLLOCATION', '[TARGETDIR]')"

Set CommandObj = MsiDbObj.OpenView(QueryStr)

CommandObj.Execute

 

QueryStr = "INSERT INTO `InstallExecuteSequence` (`Action`, `Condition`, `Sequence`) VALUES ('InstallLocation', 'NOT Installed', '1500')"

Set CommandObj = MsiDbObj.OpenView(QueryStr)

CommandObj.Execute

MsiDbObj.Commit

Wscript.Quit 0

Important points about table columns:

1. Action: It is the any name of the action.

2. Type: It the type of an action. To set any property type is 51.

For more detail go through the link : http://msdn.microsoft.com/en-us/library/aa372048(v=vs.85).aspx

3. Source: It the propert name. To know more about propery ARPINSTALLLOCATION go the link

http://msdn.microsoft.com/en-us/library/aa367589(v=VS.85).aspx

4. Target: It is the execution parameter.

To know about InstallExecuteSequence go through the link : http://msdn.microsoft.com/en-us/library/aa369500(v=vs.85).aspx

Step 2:

“c:\app\InstallLocation.vbs” “$(BuiltOuputPath)”

Step 3:
Build the window installer project.Open the properties of your installer project at set the PostBuildEvent

150 150 Burnignorance | Where Minds Meet And Sparks Fly!