Scripting Question

File key as a property?

04/28/2015 1108 views
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:


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


  • 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.

Be the first to answer this question

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ