sasjaq
sasjaq

Reputation: 771

Get msi installer filename from custom action script

we have msi installer build with MSI Factory with a couple of custom action scripts (lua & vbs). one of the scripts try to get a custom property from package and write it to file after successfully installation. this custom property is added to downloaded package via MSI.ChangeMSIProperty in asp.NET handler when download was requested with parameters. problem is, that property change brokes the signature of msi file, so we try to add some data to the msi filename. now I need to change that vbscript to handle this. but I can't get the installers filename.

Dim data, tokens
Dim fso, f
Dim setupExeFilename, setupExeFilenameParts

data = Session.Property("CustomActionData")
tokens = Split(data,"|")

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.CreateTextFile(tokens(0) & "\\data.txt", True)

    if tokens(1) = "_DEFAULT_" then
        setupExeFilename = Session.Property("SETUPEXENAME")
        setupExeFilenameParts = Split(data,".")
        f.Write setupExeFilenameParts(UBound(setupExeFilenameParts) - 1)
    else
        f.Write tokens(1)
    end if

f.Close

I found Session.Property("SETUPEXENAME") somewhere but doesn't work for me. I search for some property in Session, Session.Property, Session.ProductProperty, Installer but no luck yet. Installer object is present as I try, but no property returns what I need.

If not Installer is nothing then
    msgbox "Installer ok"
    msgbox Installer.version
end if

is it possible to get the installer filename?

Upvotes: 1

Views: 1704

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55601

The OriginalDatabase property has what you are looking for. However your reference to CustomActionData tells me your custom action is running in the deferred context. You won't have access to this property. Whatever custom action that is running in immediate and serializing your CustomActionData property will have to obtain this property and put it into CustomActionData.

You should be warned that VB/JScript custom actions are famous for their fragility. You mention SETUPEXENAME so I assume you are using InstallShield as this is an InstallShield property. I'd suggest using InstallScript, C/C++ or C# instead. If you choose InstallScript, I have a sample CustomActionData serialization/deserialization pattern over on InstallSite.org. If C#, it's built into the Microsoft.Deployment.WindowsInstaller library's Session class.

Upvotes: 2

Related Questions