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...

4 comments:

  1. Mahesh KhandalkarJune 11, 2010 at 1:12 AM

    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