Mann D

Mann D

  • NA
  • 4
  • 0

close cmd.exe in task manager from C# windows application

Jan 14 2010 12:03 AM


problem wiht cmd.exe
  i have to terminate cmd.exe(from task manager process) from C# windows application. The cmd.exe is opened as i am running my example.bat file in background. but when i want to stop that running batch file i have to terminate cmd.exe in task manager.  
  so i wrote this code :
string processName = "cmd";
Process[] processes = Process.GetProcessesByName(processName);
try
{
foreach (Process process in processes)
{
process.Close();
}
}
catch (Exception ez)
{
MessageBox.Show(" No Cmd open");
}
 
 
but not working.... any one having solution????????

p.Kill(); is closing cmd.exe  Excellent
but at same time its throwing exception : Acees is Denied..

Answers (1)