c# - Process.Kill() returns access denied -


I'm trying to kill a process using a CMD command line from my C # application, but when I start the application does not happen anything. .. When I try to kill with a command prompt, I get the message: "Access denied" I tried to run as my app administrator and the process was killed. How can I not always use "Run as administrator"?

Code:

  System.Diagnostics.Process process = new System.Diagnostics.Process (); System.Diagnostics.ProcessStartInfo startInfo = New system. Diagnostics. Process STARTINFO (); StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; StartInfo.FileName = "cmd.exe"; StartInfo.Arguments = "/ C Tasky / F / IM APP.exe"; Process.start.info = startInfo; Process.start ();    

try it

  System.Diagnostics.Process Process = new system Diagnostics Process (); System.Diagnostics.ProcessStartInfo startInfo = New system. Diagnostics. Process STARTINFO (); StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; StartInfo.FileName = "cmd.exe"; StartInfo.UserName = "Administrator"; StartInfo.Password = & lt; Password & gt; StartInfo.Arguments = "/ C Tasky / F / IM APP.exe"; Process.start.info = startInfo; Process.start ();    

Comments

Popular posts from this blog

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

c# - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments -