public override void Install(IDictionary stateSaver) { try { base.Install(stateSaver); FileInfo fileInfo = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); //Take custom action data values string sProgram = Context.Parameters["Run"]; sProgram = Path.Combine(fileInfo.DirectoryName, sProgram); Trace.WriteLine("Install sProgram= " + sProgram); OpenWithStartInfo(sProgram); } catch (Exception exc) { Context.LogMessage(exc.ToString()); throw; } }
void OpenWithStartInfo(string sProgram) { ProcessStartInfo startInfo = new ProcessStartInfo(sProgram); startInfo.WindowStyle = ProcessWindowStyle.Maximized; string[] ExcludeKeys = new string[] { "run", "WaitForExit" }; startInfo.Arguments = ContextParametersToCommandArguments(Context, ExcludeKeys); Trace.WriteLine("run the program " + sProgram + startInfo.Arguments); Process p = Process.Start(startInfo); ShowWindow(p.MainWindowHandle, WindowShowStyle.Show); //otherwise it is not activated SetForegroundWindow(p.MainWindowHandle); BringWindowToTop(p.MainWindowHandle); //make sure the user will see the new window above of the setup. Trace.WriteLine("the program Responding= " + p.Responding); if ((Context.IsParameterTrue("WaitForExit"))) { p.WaitForExit(); //have to hold the setup until the application is closed. } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)