Home > .Net, General > How to kill applications and Processes on remote machine

How to kill applications and Processes on remote machine

How to kill applications/Processes on remote machine
One of the requirements was to reboot processes that are running on Server machine, were number of possibilities how to implement such task and not to break our distributed design. Finally we decide to run simple script that kills desired processes.

After quick search on the web I have decided to use taskkill utility which supplied desired functionality.

As alternative tool we have tried pskillsysinternal development command, works nice but I failed to set force kill, so there were cases when the pskill operation didn’t succeeded.

Pskill usage example:

pskill \\serverName -u administrator -p password Process1.exe


taskkill usage example:

taskkill /s serverName /f /u administrator /p system /t /im Process1.exe


I created .BAT file with list of restart candidate processes.

Took me a while to find the option how not to open cmd console window when running batch command. The answer was very simple by using WindowStyle enum set to Hidden.


Following C# example demonstrates the usage of batch file from .Net code.

private static void RestartServerProcesses()
        ProcessStartInfo startInfo = 
                new ProcessStartInfo("RestartProcesses.bat") 
                        {WindowStyle = ProcessWindowStyle.Hidden};


Important note as you probably noticed: in order to kill process on remote computer, you need administrative privileges on that computer.

Categories: .Net, General Tags:
  1. No comments yet.
  1. No trackbacks yet.