cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Naveed
Level 6

How to get path of Installation directory.

How to get path of Installation directory. e.g. I double clicked the msi packafe in a directory, msi package is launched. How and at what event I can get current directoy where msi package is placed?

During installation, I need current directory path for use in a vbs custom action.

Thanks
Naveed
Labels (1)
0 Kudos
(7) Replies
ChandanOmkar
Level 8

for installscript it is SRCDIR.
there should be same for VBscript too.
0 Kudos
Not applicable

VBS property name is SETUPEXEDIR

example
szStringVal = Session.Property("SETUPEXEDIR")
0 Kudos
cbragg
Level 7

Actually for a basic msi project and vbscript custom actions it's

myinstallationdir = Session.Property("INSTALLDIR")

you don't need to create the Session object.

However if your custom action makes any changes to the machine best practice is to make this action deferred and if it's deferred you don't have access to most properties so it's a slightly different mechanism to get the installdir. To do this:

- Create a set property custom action, call it whatever you like and i prefer to put these just before costfinalize
-If your other custom action is called SetStuffCA then in your set property action set the property name SetStuffCA. Then set the value to [INSTALLDIR]
-In your custom action instead of referring to INSTALLDIR, you refer to CustomActionData. This will contain the values passed in from the set property action.

If you have more than one property to pass to your custom action you may want to set the property to something like this [INSTALLDIR],[ANOTHERPROPERTY],1,test,[SOMEPROPERTY]. Then all you need to do is split the value at the commas within the vbscript
0 Kudos
ChandanOmkar
Level 8

Hi cbragg,

INSTALLDIR is the location where the application files gets installed but the SRCDIR or SETUPEXEDIR is the location where the setup.exe or the msi package resides during the installation.

and i think Naveed is asking about SETUPEXEDIR not the INSTALLDIR.
0 Kudos
cbragg
Level 7

you're right 😮 I should learn to read more carefully :rolleyes:
0 Kudos
Naveed
Level 6

Yes. I am looking for Directory where my MSI package resides i.e. SetupExeDir

I have tried getting value if "INSTALLDIR" it gives me "System32" folder, which is the location of Windows Installer exe.
0 Kudos
Videstra
Level 7

And in case anyone is interested I have found that INSTALLDIR is not actually available as a session property until After Cost Finalize. Use of Session.Property("INSTALLDIR") prior to cost finalize returns an empty string.

Des
0 Kudos