Just wondering if you could use the file key is a property in the same way you can use a directory as a property?

I.e. if you run a simple custom action script:

a=Session.Property("[INSTALLDIR]")
msgbox(a)

It will print the path to INSTALLDIR.

I was hoping I could do the same thing with a file key from the File table. Doesn't seem to work though. Anyone have any information or knowledge about this? If I can pull the full path to the file I don't have to hardcore the file path or the filename in my script. (I get that I can use the directory and then hardcode the file name but kind of wished I could be even smoother.)
3 Comments   [ + ] Show Comments

Comments

  • Perhaps if you were to give an actual example of what you are trying to achieve it would be more likely to receive a response.
    The file table does not generate any properties that can be used, but I'm not clear on what you wish to achieve.
    • I run a custom action VBscript at the end of the installation (deferred) that reference a file from the installation (i.e. from the File table). I would like to just retrieve the full file path in my script instead of using:

      strFile = Session.Property("INSTALLDIR") & "Filename.exe"

      Now if you change filename.exe then you'll have to update the custom action script to reflect this change. However if you could simply use the file key (first column in File table) the same way you retrieve the INSTALLDIR then you'd be completely future-proof.

      I guess it's simply not supported, at least not in any easy way, but I figured it should be :)
  • Actually, now that I understand what you are trying to do, it isn't really that difficult. First of all, I think you might want to consider moving the custom action to after InstallFinalize, since any error causing a rollback after your script could leave things in an indeterminate state. Better to know that the install has completed successfully and then run your script. Aside from that, you can run SQL-type commands to read information from the MSI tables, so it would be trivial to search for the filekey and then read the corresponding filename into a property. I don't have example code on the laptop I am using at the moment, but if you have the Windows Installer SDK downloaded and available to you, there is a whole directory of example VBScripts that work with the tables.
    For the record, you can even dynamically change the tables during install or uninstall if the need arises.
    • Sounds mildly complicated to achieve something rather simple. I would love for examples if you happen to have any on-hand, however.

      In regards to putting the action after InstallFinalize I understand your point. I've simply added a "On Error Resume Next" in the VBScript custom action that runs however, so it can never fail and cause the installer to become "stuck".
  • in theory if you are running the script in the MSI session that exposes [INSTALLDIR], you could also use [#filenameKEY], that should resolve to the full path of the file. or [!filenameKEY] (for the short path to the file
    • That is what I was hoping would work, but it does not. Probably because in the Windows Installer world it is not a property. You can do this within the registry or shortcut table for instance but I'm sure it's a different technical mechanism in the background.
Please log in to comment

There are no answers at this time

Answers

Answer this question or Comment on this question for clarity