HOw to get the directory from where the msi is being executed?

Jun 22, 2016 at 3:25 PM
Hi,

I guess my question is clear enough. Could some one help me with this.

Thanks
Coordinator
Jun 24, 2016 at 5:14 AM
It's rather difficult.

WiX session object has the member that is supposed to give the assess to the file name:
var msiFile = e.Session.Database.FilePath;
But unfortunately because of WiX limitation or MSI bug the property is always empty. Meaning that if you indeed need to know the path you will have to do ir a hard way. Traverse up the parent process until find msiexec.exe and then discover the command line parameters containing the full path to your msi.
Jun 27, 2016 at 1:54 PM
You can try this
MsiRuntime.Session["OriginalDatabase"]
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370562(v=vs.85).aspx
Coordinator
Jun 28, 2016 at 7:50 AM
Excellent. Thank you for sharing. SetupEventArgs from the start had a dedicated property for the msi file location. Though it was disconnected as Session.Database.FilePath was broken. I am happy to use Session["OriginalDatabase"] as a work around and the next release (the code is already committed) SetupEventArgs will be properly initialized:
static void project_Load(SetupEventArgs e)
{
    var msi = e.MsiFile;
...