[wix-users] Having issue running an executable from package in a managed custom action

Tigran Galoyan tigran.galoyan at gmail.com
Tue Feb 21 06:37:01 PST 2017


Hi all,


I have a MSI package that besides the actual components to be installed
also on the target machine also has an executable, that should not be
installed, rather just be launched after a successful installation in the
managed custom action. The custom action code snippet is the following:








*public class CustomActions{    [CustomAction]    public static
ActionResult CAM_RunDComPerm(Session session)    {        try
{            string path2DComPermExe =
Path.Combine(Assembly.GetExecutingAssembly().Location, "DComPerm.exe");*










*            using (Process proc = Process.Start(path2DComPermExe, "-runas
\"{SOME-GUID}\" username password"))            {
proc.WaitForExit(5000);            }                            return
ActionResult.Success;        }        catch (Exception ex)
{            session.Log("ERROR in CAM_RunDComPerm custom action {0}",
ex.ToString());*



*            return ActionResult.Failure;        }    }}*

What it does exactly, it sets some DCOM settings for a specific component
that gets installed as part of the MSI package. To do that I run a special
tool DComPerm.exe with the "-runas \"{SOME-GUID}\" username password"
command line arguments.

To call the custom action I have the following in my main wxs file:



*<InstallExecuteSequence>     <Custom Action="CA_LaunchDComPerm"
After="InstallFinalize">NOT Installed</Custom></InstallExecuteSequence>*

*<Binary Id="MyInstallerCustomActions" SourceFile
="..\Output\MyCustomActions.CA.dll" />*
*<CustomAction Id="CA_LaunchDComPerm" Return="check"
BinaryKey="MyInstallerCustomActions" DllEntry="CAM_RunDComPerm"
Impersonate="no" />*

However, the custom action call fails right at the beginning when combining
the path to get the absolute path to the DComPerm.exe tool to be called.
Looks like it cannot figure out the absolute path to the tool in the MSI
package. I don't want to install that tool along with other components and
then launch it at the end from the INSTALLDIRECTORY (my target directory to
install to), but to simply launch it as it exists in the package.
Unfortunately cannot specify the absolute path to it.

Any help how to make this happen?


Thanks,
Tigran


More information about the wix-users mailing list