title: How do I close the on-screen keyboard process from C# winform correctly?
body: <p>I'm currently designing an image viewer that allows the user to input her e-mail and get the images digitally. The part that troubles me is getting the on-screen keyboard to close. I use this piece of code to start the windows process:</p>
  
  <pre><code>string progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
  string keyboardPath = Path.Combine(progFiles, "TabTip.exe");
  Process keyboardProc = Process.Start(keyboardPath);
  </code></pre>
  
  <p>After which i open a VB InputBox to prompt for the e-mail address (for which i use the on-screen keyboard, since the application will be shown on a touch screen). After this prompt I want to close the process automatically.</p>
  
  <p>I've tried to close the process with the following:</p>
  
  <pre><code>keyboardProc.Kill();
  keyboardProc.Dispose();
  keyboardProc.Close();
  keyboardProc = null;
  </code></pre>
  
  <p>None of them works and simply throws the exception:</p>
  
  <pre><code>An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
  Additional information: Cannot process request because the process has exited.
  </code></pre>
  
  <p>I also tried identifying the process by ID and closing it this way, didn't work either.
  I also had a look at:
      <a href="https://stackoverflow.com/questions/2532202/c-net-closing-another-process-outside-the-main-window">C#/.NET: Closing another process outside the main window</a>
  but didn't get it working either.. :(</p>
  
  <p>I'm pretty new to C# and this is the first time I've invoked a windows process from code - am I missing something?</p>
  
  <p>Thank you very much in advance!</p>