Finding current msi location and passing it to vbs - Advanced Installer Community
cianchet
Posts: 1
Joined: Tue Mar 28, 2017 4:16 pm

Finding current msi location and passing it to vbs

Hello,

I would like to create a custom action that:

- finds current location of the msi bundle,
- uses the current location to a vbs that uses it to read a file

What could the easiest solution be?
Can you please help?

Thanks
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Finding current msi location and passing it to vbs

Hello and welcome to our forums,

To find the MSI location you should use the "SOURCEDIR" property which stores the location of the executed MSI setup.

Secondly to use the property in your VBS custom action you can use the following syntax in your script:

Code: Select all

MyVariable = Session.Property("SOURCEDIR")"

but please note that your custom action should run as "Immediately" (Execution Time). Otherwise the property can not be accessed from your VBS script.

More information about how to set and get a property in your script are found in our "Set an installer property using custom actions" article.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Finding current msi location and passing it to vbs

Is SOURCEDIR defined during silent installs? From my tests, the only property that works in all scenarios (silent vs non-silent and setup.exe vs msi) is the "OriginalDatabase" property. The screenshot below shows the results from my test:
PropertyCompare.PNG
PropertyCompare.PNG (28.87 KiB) Viewed 7439 times
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Finding current msi location and passing it to vbs

Hello,

During a silent installation the SOURCEDIR property is defined after "AllocateRegitrySpace" action. So you should make sure you place your custom action after "Installation Execution Stage -> Preparing -> AllocateRegistrySpace" standard action. Starting with this execution point the SOURCEDIR is set to the MSI path and it's available until "Installation Execution Stage -> Finish Execution -> InstallFinalize" standard action.
image.jpg
image.jpg (171.43 KiB) Viewed 7424 times
Also you should configure to run your custom action as Immediately, otherwise if you want to run it as Deferred you need to pass the SOURCEDIR property throught CustomActionData. You can find more information about deferred custom actions in our "Access installer properties from deferred custom actions" article.

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Finding current msi location and passing it to vbs

During a silent installation the SOURCEDIR property is defined after "AllocateRegitrySpace" action.
Ahh, I did not know that. I was indeed checking the values before AllocateRegitrySpace. Thanks!
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Finding current msi location and passing it to vbs

You're always welcome.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”