1

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?

sasjaq
  • 761
  • 1
  • 11
  • 31

1 Answers1

2

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.

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • right now I was writing answer to my own question. You are absolutely right, OriginalDatabase was the solution, and yes, custom action runs in deffered context :) my solution was to append `|[OriginalDatabase]` to my CustomActionData and read it as token(2) – sasjaq May 29 '13 at 13:21
  • FWIW, you could eliminate this custom action. You could use an immeadiate custom action to do your file path parsing and just set a bunch of properties and then use the INI Changes View to write it out in INI format. This would not introduce problems such as rollback, uninstall issues. – Christopher Painter May 29 '13 at 14:02