cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
BigAlbert
Level 3

Adding component using code?

Is it possible to add component to exiting Msi using code (not by Install Shield \ Orca)? If so, which Msi methods should be used? In which sequence?
Labels (1)
0 Kudos
(2) Replies
RobertDickau
Flexera Alumni

Do you intend to add the component at build time, or some other time? For build time, there's the InstallShield Automation interface (about which see the InstallShield help topic "AddComponent Method") or the Windows Installer Automation interface (about which see the MSI help library).

Please keep in mind this might cause problems with future updates, if your component GUID is a random value each build...
0 Kudos
Cygnusx1
Level 8

Simple vbscript...

Set oInstaller = CreateObject("WindowsInstaller.Installer")
Dim sMSI
sMSI = ""

Set Database = oInstaller.OpenDatabase(sMSI,1)
Set TypeLib = CreateObject("Scriptlet.TypeLib")

Set View = Database.OpenView("INSERT INTO Component (`Component`,`ComponentId`,`Directory_`,`Attributes`,`Condition`,`KeyPath`)"_
" VALUES ('CompName','" & Left(TypeLib.Guid,38) & "','TARGETDIR','4','','Registry.0')")
View.Execute
View.Close
Database.Commit

Do not forget to add the Component to the FeatureComponent Table and to add your own error checking.
0 Kudos