cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Anonymous
Not applicable

Get short file name for a directory

Does anyone know a way to get the short file name of a directory (specifically INSTALLDIR) without using scripts?

This is for a Basic MSI.

Thanks.
Labels (1)
0 Kudos
5 Replies
Ajay_Ladsaria
Level 7

Take a look at the following Windows Installer documentation:

Formatted
http://msdn.microsoft.com/en-us/library/aa368609(v=VS.85).aspx

You can use [!filekey] syntax with a file key for a file that is set to be installed to INSTALLDIR. This will give you a short path including that file name. If you didn't want the file name as part of it, then you may need to use a custom action of some sort to strip out the file name part from the path.

-Ajay
0 Kudos
Anonymous
Not applicable

There is no file. Just a directory.

I tried setting my environment variable to [!INSTALLDIR], but it didn't work. It was just blank.

Would I use a CA to set a property? Like maybe NEWINSTALLDIR = [!INSTALLDIR]?
0 Kudos
Ajay_Ladsaria
Level 7

Hi,

You need to use a file key in [!filekey] to get a short path to the file. File keys can be found in the first column of the File table which you can see in the Direct Editor view. Note that INSTALLDIR is actually a directory key and not a file key.
0 Kudos
Anonymous
Not applicable

Oh I get it. Thanks so much!

What kind of CA should I use to strip the filename though?
0 Kudos
Ajay_Ladsaria
Level 7

The custom action to use will depend on your preferences. It may be easiest to use a vbscript custom action. Or you may want to go with a C++ MSI DLL or a C# DLL. The downsides of vbscript include, rarely, there is an issue with the Windows Scripting Host on a machine that prevents vbscript custom actions from running. Also, infrequently/rarely, there is an issue where an anti-virus software prevents vbscript custom actions from running. The downsides of C++/C# is that it is a bit harder to implement from scratch.
0 Kudos