1

I`m use WIX.sharp for create msi. Please help me: how to run exe file after installation servise? Now it leads to an error (when I use my msi). My application starts for init cofiguration file of service. Now it seems like this:

project.Binaries = new[]
{
    new Binary(new Id("StartAdmin"), "xxx.exe")
};

project.Actions = new WixSharp.Action[]
{
    new BinaryFileAction("StartAdmin", "Executing ...", Return.check, When.After, Step.InstallExecute, Condition.NOT_Installed)
    {
        Execute = Execute.commit
    }
Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
  • Could you simply start a process of the application? Like here: https://stackoverflow.com/questions/181719/how-do-i-start-a-process-from-c – Marvin Klar Mar 22 '19 at 10:05
  • I need to run my admin.exe within the implementation msi for service. 1) Start Install service 2) Start admin.exe for configure the configuration file of the service 3) End work of msi – Тигрик Смугастий Mar 22 '19 at 10:23
  • [There is a related discussion](https://github.com/oleg-shilo/wixsharp/issues/479#issuecomment-424964739), over in the WixSharp GitHub area. – Uwe Keim Jun 18 '19 at 08:03

1 Answers1

2

Thanks. I did what I asked. I want to share the result.

using Microsoft.Deployment.WindowsInstaller;
...
var project = new Project("Application Name", GetAllEntities(releaseDir, parentDir, out service));
...
private static Dir GetDirs(string releaseDir, string parentDir, out File service)
        {
            var docDir = System.IO.Path.GetFullPath(System.IO.Path.Combine(parentDir, @"pub\\doc\\"));
            return new Dir(new Id("SERVICEDIR"), @"%ProgramFiles%\Application\",
            new Dir(new Id("INSTALLSERVICEDIR"), "App name",
                new Dir(new Id("BINSERVICEDIR"), "bin",
    ...
                    new File(string.Format("{0}{1}", releaseDir, "Admin.exe")),
...
project.AddAction(new ManagedAction(CustomActions.MyAction, Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed));
...
public class CustomActions
{
    [CustomAction]
    public static ActionResult MyAction(Session session)
    {
        System.Diagnostics.Process process = new System.Diagnostics.Process();
        process.StartInfo.FileName = string.Format("{0}\\Admin.exe", session["BINSERVICEDIR"]);
        process.StartInfo.Arguments = "-n";
        process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
        process.Start();
        process.WaitForExit();

        return ActionResult.Success;
    }
}