title: launching an external program from asp.net
body: <p>I have a question regarding launching an external application from an asp.net website. Now I think there are security measures in place to prevent that and I know it's not a good practice, but for an intranet site I'm developing it would be incredibly handy to be able to do that. </p>
  
  <p>So far I've found where I can launch an external app if I'm running my server locally (in  debug) then it works fine. When I publish the files out to my webserver it no longer works. I know my filepaths are going to be different I imagine, but how can I check if a local file exists? Or can I?</p>
  
  <p>So here's my code:</p>
  
  <pre><code>//the actual launch button on the page
  protected void btnLaunchTnet_Click(object sender, EventArgs e)
  {
      string tnetpath = "c:\path\tnet.exe";      
      RunProcess(tnetpath, "");
  }
  
  
  private void RunProcess(string cmd, string arguments)
  {
      System.Diagnostics.Process p;
      p = new System.Diagnostics.Process();
  
      p.StartInfo.FileName = cmd;
  
      if (arguments.Length &gt; 1)
      {
          p.StartInfo.Arguments = arguments;
      }
      p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
      p.StartInfo.RedirectStandardOutput = false;
      p.StartInfo.UseShellExecute = false;
      p.Start();
  }
  </code></pre>
  
  <p>I also have a quick 'check if this file exists' that I use to disable or enable the button that launches the app</p>
  
  <pre><code>private bool CheckFileExists(string filepath)
  {
      FileInfo SetupPath = new FileInfo(filepath);
      return SetupPath.Exists;
  }
  </code></pre>