It is retrievable according to Microsoft documentation (Sourcedir).
The SourceDir property is the root directory that contains the source cabinet file or the source file tree of the installation package. This value is used for directory resolution.
In some projects, i am making it would be great to be able to load a file for example a logo or settings file, from the path as the msi is running from.The ResolveSource action must be called before using the SourceDir property in any expression or attempting to retrieve the value of SourceDir with MsiGetProperty. The ResolveSource action should not be run while the source is unavailable, such as when uninstalling an application, because this can cause an unintended prompt for the source media.
I have found an "ugly" way to accomplish this (reading from the eventlog, and substring away the "installer.msi"), but if it was built in, it would fail the install if the file was not present. I have tried some myself, but im not sure how i can retrieve the Sourcedir from MsiGetProperty.
Ugly "solution" that i run from installdir, after install:
Code: Select all
$r = get-winevent -FilterHashtable @{ Logname = "Application"; ID = 1040 } -MaxEvents 1
[xml]$evt = $r.ToXml()
$installfromlocation = $evt.Event.EventData.Data[0]
$installfromlocation = $installfromlocation.Substring(0, $installfromlocation.lastIndexOf('\'))
$settings = "$installfromlocation\Configure\Settings.config"
$logo = "$installfromlocation\Configure\Logo.png"
I am not allowed to link yet, but a google search on "SourceDir property" first hit is Microsoft.