diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs index 8b89d93..5b8aa63 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Stubs/OutlookWrappers/AddInWrapper.cs @@ -150,7 +150,7 @@ namespace Acacia.Stubs.OutlookWrappers // Run that Process process = new Process(); - process.StartInfo = new ProcessStartInfo(path, Environment.CommandLine); + process.StartInfo = new ProcessStartInfo(path, Process.GetCurrentProcess().Id + " " + Environment.CommandLine); process.Start(); // And close us and any other windows diff --git a/src/AcaciaZPushPlugin/OutlookRestarter/Program.cs b/src/AcaciaZPushPlugin/OutlookRestarter/Program.cs index 7f774a4..fb96d83 100644 --- a/src/AcaciaZPushPlugin/OutlookRestarter/Program.cs +++ b/src/AcaciaZPushPlugin/OutlookRestarter/Program.cs @@ -17,20 +17,45 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace OutlookRestarter { class Program { + + /// + /// Entry point. + /// Arguments: + /// 0 - parent pid + /// 1 - parent path + /// 2 - arguments + /// n - ... + /// + /// [STAThread] static void Main(string[] args) { - Process process = new Process(); - process.StartInfo = new ProcessStartInfo(args[0], string.Join(" ", args.Skip(1))); - process.Start(); + string procPath = args[1]; + var procArgs = args.Skip(2); + try + { + // Attempt waiting for the process to finish + int procId = int.Parse(args[0]); + Process proc = Process.GetProcessById(procId); + proc.WaitForExit(15000); + } + finally + { + // Start the process + Process process = new Process(); + process.StartInfo = new ProcessStartInfo(procPath, string.Join(" ", procArgs)); + process.Start(); + } } } }