title: Get the window handle of the Windows setup process
body: <p>I am trying to automate Windows 10 installation by first mounting the .iso file on the drive. And then using c# to start windows 10 installation by using this below code which passes the keys to the installation application</p>
  
  <pre><code>[DllImport("user32.dll")]
  static extern int SetForegroundWindow(IntPtr point);
  public static void Main(String[] args){
      Process p1 = Process.Start("h:\\setup.exe");
      IntPtr h = p1.MainWindowHandle;
      SetForegroundWindow(h);
      Thread.Sleep(30000);
      SendKeys.SendWait("{ENTER}");
      Thread.Sleep(1000);
      SendKeys.SendWait("{ENTER}");
      Thread.Sleep(1000);
      SendKeys.SendWait("{ENTER}");
  }
  </code></pre>
  
  <p>But the problem is that the setup window is not taking the signal of the ENTER key in the code. The setup window is starting with this code. After that, nothing is happening.</p>
  
  <pre><code>Process p1 = Process.Start("h:\\setup.exe");
  </code></pre>
  
  <p>I tried using notepad instead of setup.exe in the code which is taking all the ENTER keys. Please tell me if anyone has a solution. Thank you</p>