title: Close a batch file ran by c#
body: <p>I have a simpel program that runs a vulnerability scan on the given port and host. Now I have to find a way to close the batch file that is run from my c# form.
  I have to be able to close the batch file from a button, even when its not finished yet. And i have no clue, nor did i find a way somewhere.</p>
  
  <p>EDIT: Added more code, but still given the error "process doesn't exist in current context"</p>
  
  <pre><code>private void button10_Click(object sender, EventArgs e)
      {
  
          if (button10.Text == "Scan")
          {
              int port = (int)numericUpDown2.Value;
              string path = Directory.GetCurrentDirectory();
              string strCommand = path + "/SystemFiles/nikto/nikto.bat";
              string host = textBox5.Text;
              Console.WriteLine(strCommand);
              richTextBox5.Text += "Starting Nikto Vulnerability Scan On " + host + " On Port " + port + System.Environment.NewLine;
  
              System.Diagnostics.Process process = new System.Diagnostics.Process();
              System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
  
              startInfo.FileName = strCommand;
  
              startInfo.Arguments = "-h " + host + " -port " + port + textBox6.Text;
              process.StartInfo = startInfo;
              process.Start();
              richTextBox5.Text += "Vulnerability Scan Started On " + host + " On Port " + port + System.Environment.NewLine;
              button10.Text = "Cancel";
          }
          else
          {
              process.Kill();
              button10.Text = "Scan";
          }
  
  
  
      }
  </code></pre>