Tip 13 : Kill a process using C#, from local to remote

1. My first choice is always to try System.Diagnostics to kill a process

2. The first choice works very well in killing local processes. I thought the first choice should work for killing remote process too because process.kill() method is overloaded with second argument of machine name. I pass process name plus remote machine name and call the process.kill() method

3. Unfortunately, it gives me error message of "Feature is not supported for remote machines.". Apparently, you can query but not kill a remote process using Process class in System.Diagnostics. The MSDN library document explicitly states that about Process class: Provides access to local and remote processes and enables you to start and stop local system processes.

4. I try my second choice: using System.Management to kill a process running on a remote machine. Make sure add references to System.Management.dll and System.Management.Instrumentation.dll

5. The second choice works very well in killing a remote process. Just need to make sure the account running your program must be configured to have permission to kill a process running on the remote machine.



  • Hi,

    I am calling example.exe from asp.net web-page.

    Example.exe contains Process.Kill(), but I am not able to kill that process whenever Ill run example.exe from asp.net web page.

    I think i need to set some permissions for killing processes.

    What permissions must a user have to be able to succesffuly execute a Process.Kill?

    Note : it is working when I double clicking on (example.exe), means its killing some processes

  • Good article! Thanks for the help, I've been searching for a while.

    Here's a tip to others that may be coming from other sites: in some cases when .NET refers to the "Process Name" they mean the name of the executable without the .exe. This is not the case so don't forget to include the extension in the process name!

  • Thanks for the snippit. I placed a link on my blog.
    Works like a charm!

  • I am trying the same with remote server than getting error : Could not connet to remote system.

    please reply me.

  • This article was really useful in my case to kill the process. I got the error as "Access Denied". May be i tried to close Excel workbook as an user that was initially opened with admin rights. Thanks

  • Super solution!! thnx a lot..

Comments have been disabled for this content.