I'm trying to kill a process using a CMD command line from my C# application but when i start the application nothing happens... When i try to kill from command prompt i recieve the message: "Access denied". I've tried to run my app as Administrator and the process was killed. How can i manage not to always use "Run as Administrator"?
Code:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C taskkill /F /IM APP.EXE";
process.StartInfo = startInfo;
process.Start();
Try this
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.UserName = "Administrator";
startInfo.Password = <password>;
startInfo.Arguments = "/C taskkill /F /IM APP.EXE";
process.StartInfo = startInfo;
process.Start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With