For many of my projects at one time or another there was a need for a Windows service. With Visual Studio, debugging a Windows service is relatively straight forward but it happens fairly often that after the debug session the Windows service keeps running. With a running service you can’t build anymore because the binaries are locked. If you don’t want to reboot (and you don’t!) you need to kill the running Windows service.  This post is mostly for myself because I always have too look up on how to kill a Windows service. These are the steps:

  1. Find the service name by going into the services and double click on the service that you want to annihilate.
  2. Find the PID (service number) of that service by opening a command prompt in administrator mode and type:
    sc queryex [servicename]
  3. Kill the PID, from the same command prompt by typing:
    taskkill /f /pid [PID]
  4. If this worked you see a success message:
    SUCCESS: The process with PID [PID] has been terminated.

You are welcome.