title: How do I open a web browser from a .NET Program? Process.Start() isn't working?
body: <p>I have a URL and I want to launch it in the default browser.  I've tried two methods:</p>
  
  <pre><code>Process.Start("http://stackoverflow.com");
  </code></pre>
  
  <p>... and the one detailed in this <a href="https://stackoverflow.com/questions/856236/net-wpf-process-start-not-working-on-vista-and-windows-2007">other question</a> using ShellExecute.</p>
  
  <p>In both cases I get the error: Windows cannot find '<a href="http://stackoverflow.com">http://stackoverflow.com</a>'. Make sure you typed the name correctly, and then try again.</p>
  
  <p>It shouldn't be trying to open it as a file though... from what I understand, it should recognize it as a URL and open it in the default browser.  What am I missing?</p>
  
  <p>By the way: OS = Vista, and .NET = 3.5</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>According to <a href="http://support.microsoft.com/kb/305703" rel="noreferrer">this MS KB article</a>, since Process.Start sets the UseShellExecute by default, it should launch the default browser.</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Here's what does work:</p>
  
  <pre><code>System.Diagnostics.Process.Start(@"C:\Program Files\Internet Explorer\IExplore.exe", "http://stackoverflow.com");
  </code></pre>
  
  <p>Unfortunately that really doesn't launch the default browser, and it also doesn't work if IE isn't installed in the "normal" place.  I'm not sure what to do here.</p>
  
  <p><strong>More information</strong>:</p>
  
  <p>OK, so the error I'm getting is error number -2147467259.  Looking at Google for this, it appears that it's not very descriptive.  It might be a file association error or something.</p>
  
  <p><strong>The plot thickens</strong>:</p>
  
  <p>So I checked the registry key that's supposed to have my file association for http:</p>
  
  <pre><code>KEY_CLASSES_ROOT\http\shell\open\command\default
  </code></pre>
  
  <p>Here's the value:</p>
  
  <pre><code>"C:\Program Files\Mozilla Firefox\firefox.exe" -requestPending -osint -url "%1"
  </code></pre>
  
  <p>That makes sense.  I actually copied this string into a command prompt and replaced the %1 with <a href="http://stackoverflow.com">http://stackoverflow.com</a> and it worked and opened firefox.  I just don't get why Process.Start isn't associating the URL with this command...</p>