using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Threading; namespace ActivateDiff { public partial class DummyWindow : Form { private string[] _args; public DummyWindow(string[] args) { _args = args; InitializeComponent(); } private void DummyWindow_Load(object sender, EventArgs e) { // make sure the window is normal or maximised // even though the default was "Normal", starting it via shell minimised it this.WindowState = FormWindowState.Normal; // only required for some scenarios this.Activate(); timer.Interval = 100; timer.Tick += new EventHandler(timer_Tick); timer.Start(); } void timer_Tick(object sender, EventArgs e) { string fullCmdLine = Environment.CommandLine; string exePath = _args[0]; int startArgs = fullCmdLine.IndexOf(exePath) + exePath.Length + 1; string exeArgs = fullCmdLine.Substring(startArgs); ProcessStartInfo info = new ProcessStartInfo(exePath, exeArgs); info.WindowStyle = ProcessWindowStyle.Maximized; info.UseShellExecute = false; Process p = Process.Start(info); p.WaitForExit(); this.Close(); } } }