Thursday, February 12, 2009

Deleting Services Forcefully from Services MMC

Few days back I modified my Windows Service .NET Application and compiled to MSI to be re-installed. Somehow during un-install process, service was not removed from Services Microsoft Management Console (MMC) and it came to my notice during re-installation of MSI.

As there is no Delete option available in Services MMC, it was becoming a nightmare to re-install it. Some how I found SC.EXE which is a command line program to communicate with Service Control Manager and Services.

There are many available options but what interested me is you can Create, Start, Stop, Delete a service with a Command Line.

Creating a Service:

sc.exe create PayCalcService binPath= "C:\Program Files\PaymentCalculation\paycalc.exe" DisplayName= "PaymentCalculationService"

Starting a Service:
sc.exe start PaymentCalculationService

Stopping a Service:
sc.exe stop PaymentCalculationService

Deleting a Service:
sc.exe delete PaymentCalculationService

Hope this helps for similar problems...

7 comments:

  1. very nice and stright forward solution. Thanx

    ReplyDelete
  2. I hoped this could help but if the service is allready marked for deletion there is no way around of restarting the server

    ReplyDelete
  3. To the comment above August 30, 2012:

    Sometimes just closing the services console and reopening rather than refreshing completes the uninstall / delete process, I think the console puts a lock on it or caches it.

    ReplyDelete
  4. I just found this article, and your method for deletion worked perfectly. Thanks!

    ReplyDelete
  5. Closing Server Manager allowed the service to be completely removed. When I re-opened Server Manager - the service no longer showed up in the list of installed services.

    ReplyDelete
  6. Really helpful - just needed a quick and clear explanation and you provided it - thank you!

    ReplyDelete