Trying to execute an installed file at the end of the setup, I tried something like this:
project.Actions = new WixSharp.Action[]
{
new WixQuietExecAction(
@"[INSTALLDIR]\adxregistrator.exe",
@"/install=""MyOutlookAddIn.dll"" /privileges=admin /returnExitCode=false"),
// ...
Which results in a 1603 exit of the setup.
Looking with Process Monitor, it seems that the action is executed _before_ the files were copied.
I then tried:
project.Actions = new WixSharp.Action[]
{
new WixQuietExecAction(
@"[INSTALLDIR]\adxregistrator.exe",
@"/install=""MyOutlookAddIn.dll"" /privileges=admin /returnExitCode=false",
Return.ignore,
When.After,
Step.InstallFinalize,
Condition.NOT_Installed),
// ...
Which does not change anything. Still seems that the files are not copied at all before calling the custom action.
(How) is it possible to run a just self-copied executable (silently) at the end of the MSI setup?
Hi Uwe,
I would go with the AfterInstall event. Particularly because it is already elevated and the all files are in place:
C#
project.AfterInstall += (SetupEventArgs e)=>
{
if (e.IsInstalling || e.IsModifying)
{
var exe = e.InstallDir.PathCombine("adxregistrator.exe");
. . .
}
};
Thank you, I'll try that.
Any chance to do the same during uninstall, too?
Yep:
C#
project.AfterInstall += (SetupEventArgs e)=>
{
if (e.IsUninstalling)
{
. . .
}
};
OMG, shame on me, this is so obvious and logical. Sorry and thanks a thousand times, Oleg!
Don't be to harsh :)
The name the even is not really ideal. Simply instead of AfterInstall, AfterUninstall, AfterUpgrade and AfterModify I opted to a single event with an event arg indicating the type of the setup session.
Now I think that the name AfterSetup would be semantically a better choice but... it's kind of too late to change the game :)
Most helpful comment
Don't be to harsh :)
The name the even is not really ideal. Simply instead of
AfterInstall,AfterUninstall,AfterUpgradeandAfterModifyI opted to a single event with an event arg indicating the type of the setup session.Now I think that the name
AfterSetupwould be semantically a better choice but... it's kind of too late to change the game :)