title: Showing a hidden process on Windows?
body: <p>I got a bit of a problem.</p>
  
  <p>Related to my earlier questions about <a href="https://serverfault.com/questions/9943/sp3-installed-vs-sp3-slipstreamed-difference-in-default-security-settings">Slipstreamed SP3 vs. patched SP3</a>, we've come to the conclusion that there is an Internet Explorer process being started, instructed to load a simple .html file from the local disk, which contains javascript, which opens up the rest of a larger chat/meeting system. Internet Explorer is started from a Lotus Notes client.</p>
  
  <p>Unfortunately, all we can see is the IExplore.exe process popping up in Task Manager, and some seconds later, disappear again.</p>
  
  <p>If we try to open the local .html file, which we've found on disk, it gives us that information bar at the top, telling us that it has disabled active content. This, however, is not the real problem. We have another machine that has the same settings but where everything works, and loading the .html file manually gives us the same error there as well.</p>
  
  <p>However, perhaps there is another error message being shown when IExplore is started from notes, but since this process is supposed to just kickstart the rest of the system, and this window is hidden, we can't see it, that is, the error message / problem.</p>
  
  <p>So, I thought, perhaps I should try creating a small program that waits for IExplore.exe to start, then immediately shows the window, so that we can see the error message, or whatever the problem is. At least, hopefully we'll be able to see that.</p>
  
  <p>So far so good, except that if I start a process from my own program, with a hidden window, the main window handle is 0, and thus I cannot show the window after all. I expect this IExplore.exe process started from Lotus Notes to have the same issue.</p>
  
  <p>My monitoring program is written in C#, and basically runs this loop:</p>
  
  <pre><code>foreach (var process in Process.GetProcesses())
  {
      if (process.ProcessName.ToLower() == "iexplore")
          result.Add(process);
  }
  </code></pre>
  
  <p>This picks up all the IExplore.exe processes, windows or not, and with IE8, I get 2 processes for the first window, as expected. I run this over and over again, and handles the differences from the previous runs.</p>
  
  <p>However, the process briefly has a window handle 0 at the start, so I changed it to this:</p>
  
  <pre><code>foreach (var process in Process.GetProcesses())
  {
      if (process.ProcessName.ToLower() == "iexplore" &amp;&amp;
          process.MainWindowHandle != IntPtr.Zero)
      {
          result.Add(process);
      }
  }
  </code></pre>
  
  <p>but now it doesn't pick up anything at all, even after the window has gotten a handle (and yes, process.MainWindowHandle does have a non-zero handle value after the window has been shown, but in the case where the window is never shown, it stays at 0.)</p>
  
  <p>So, the question is: Is there any way for me to take this hidden IExplore.exe process, and instruct it to show itself, when it doesn't have a window handle already? I doubt it, but perhaps someone can prove me wrong.</p>
  
  <p>If not, my backup plan is to create a shim IExplore.exe program, that forwards all command line arguments to the original one, except that it specifies that the window is to be shown. Would this be a solution?</p>