Nuo Yan

Problem Solved

Recent Posts

Tags

News


  • Follow me on twitter: @nuoyan
    Make a donation to this Blog by PayPal. Thanks!






    Nuo is currently a Software Development Engineer in a Seattle-based software company.




    Locations of visitors to this page

    The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my school or employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.


Community

Email Notifications

Archives

Deleting services in Windows Server 2003

We can use sc.exe in the Windows Server 2003 to control services, create services and delete services. Since some people thought they must directly modify the registry to delete a service, I would like to share how to use sc.exe to delete a service without directly modifying the registry so that decreased the possibility for system failures.

To delete a service: 

Click “start“ - “run“, and then enter “cmd“ to open Microsoft Command Console.

Enter command:

sc servername delete servicename

For instance, sc \\dc delete myservice

(Note: In this example, dc is my Domain Controller Server name, which is not the local machine, myservice is the name of the service I want to delete on the DC server.)

Below is the official help of all sc functions:

DESCRIPTION:
        SC is a command line program used for communicating with the
        NT Service Controller and services. 
USAGE:
        sc [command] [service name] ...

        The option has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistant).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc


Comments

Nuo Yan said:

ok but when we want nobody delete service ... how we can do ?
# December 30, 2004 4:37 AM

Nuo Yan said:

You can use the to restrict Windows XP and Windows Server 2003 clients from opening and editing the registry. Without editing the registry, they cannot delete a service.

By searching microsoft.com web site, you can get more information about Software Restriction Policies.

Thank you.
# January 3, 2005 8:27 PM

Nuo Yan said:

Hi,
When I go to command prompt and type sc it gives the following message:

'sc' is not recognized as an internal or external command,
operable program or batch file.

I am not able to locate sc.exe on my machine also, how to go about it.
Pls mail to sarathshiva_19@yahoo.com.

Thanks,
sarath.
# February 9, 2005 2:10 AM

Nuo Yan said:

What OS are you using?
# April 5, 2005 10:32 PM

Nuo Yan said:

My email, xelizondo@banxico.org.mx
# April 5, 2005 10:44 PM

TrackBack said:

^_~,pretty good!
# April 17, 2005 8:16 PM

Nuo Yan said:

Great Help Nuo Yan.

I wanted to deleted Oracle 10g Services with your help i succeeded in doing so,
THANKS Nuo Yan

PROOF
---------
D:\Documents and Settings\imrant>sc delete OracleCSService
[SC] DeleteService SUCCESS

D:\Documents and Settings\imrant>sc delete OracleDBConsoleorcl
[SC] DeleteService SUCCESS
D:\Documents and Settings\imrant>sc delete

OracleOraDb10g_home1TNSListener
[SC] DeleteService SUCCESS
# June 5, 2005 3:04 PM

Nuo Yan said:

You're welcome, Majid Hameed.
Thanks for visiting.
# June 5, 2005 7:34 PM

Nuo Yan said:

Few things to keep in mind (for those less fortunate to be experienced with cmd line):

1. By default, the query only produces the running service output. To query all services (stopped/started), run the following command.

sc query state= all

This will probably produce a veeeery long list of services. Keep in mind that Displayed service name and actual service name may be different, as in this example:

SERVICE_NAME: MMRot
DISPLAY_NAME: PureMessage Running Object Table
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

This means that in Service applet, you will see the "display name" variable. What you want to delete is the "service name" variable.

To do that, you'd need to find it. The way to do it, is run a query and redirect it to a .txt file output (standard redirect options work). Here's how:

C:\>sc query state= all > svc.txt

This will redirect the output of command to svc.txt file in the root of C:

2. Next, open the file in the notepad or other text editor and search for the "display name" variable. Right above it, you will find the actual "service_name" variable. That's the one you need to specify to delete the service.

3. Execute your command (you'll need local admin rights):

C:\>sc delete mmrot
[SC] DeleteService SUCCESS

that's all, folks!

Cheers,

-Karl
# June 16, 2005 9:42 PM

TrackBack said:

Deleting services in Windows Server 2003ooeess
# July 22, 2005 7:20 PM

TrackBack said:

# August 3, 2005 6:45 AM

TrackBack said:

Deleting services in Windows Server 2003ooeess
# August 3, 2005 8:59 PM

Nuo Yan said:

Nuo, Does this replace the method of using SRVANY to create a user defined service? If so how do you configure the service once you have created it using SC?

Thanks
Christian
# September 27, 2005 7:34 AM

TrackBack said:

SC.exe in Windows 2000
I have an old blog article regarding the use of SC.exe in Windows Server 2003...
# October 19, 2005 10:16 PM

Jai said:

I want to delete the service from the 'Services' of the Component Services adminstrative tool. I used 'sc delete resin-a'.
But it is still visible in the services list.

When I tried the command for the second time, I got an error 'It is already marked for deletion' It means it is not yet deleted. How to commit the changes?
# January 16, 2006 2:20 AM

rape stories said:

Your article is prety nice. It's a pity that i didn't see it more later.
# June 20, 2006 2:56 AM

rajesh said:

How to check the staus of service in remote machine by providing username and password

# February 14, 2007 5:30 AM

Akely said:

Thanks a bunch! Your article helped me get rid of a service that threw an alert constantly. It turned out to be PfModNT which is a CreativeLabs service. The software is uninstalled but the service still tried to call the files, errors ensued.

Again, thanks!

# July 18, 2007 4:30 PM

Leigh said:

[SC] DeleteService FAILED 1072:

The specified service has been marked for deletion.

The service is MySQL and it cannot be started or deleted. Any idea what to do next?

# October 16, 2007 12:03 AM

Nuo Yan said:

Hi Leigh,

There are several comments in this article (jayseae.cxliv.org/.../manually_remove_a_windows_service.php) seems to be in same situation as your problem.

Some are:

First disable MySQL service, try to desinstall all MySQL packages, delete all files and folders (for MySQL, mysql admin etc) and then use sc command line tool. It works for me.

-------

The error 1072 (mentioned by James in comment 10) is probably caused by the service being referenced by some other process so it can't be deleted. However, 1072 is "Marked for Deletion" according to my microsoft documentation, and the next time you reboot the service will be deleted.

----------

# October 16, 2007 12:12 AM

Tina said:

Hi nuoyan,

The information provided was very helpful for me. Thanks a lot to you.

# December 21, 2007 11:44 AM

Tina said:

Hi nuoyan,

Can this file www.dynawell.com/.../sc.zip be used for windows server 2003 or just for windows-2000?

# December 26, 2007 2:44 PM

Nuo Yan said:

In Windows 2000, sc.exe is provided as a resource kit utility. In Windows Server 2003, sc.exe is a buit-in tool.

# December 26, 2007 7:05 PM

Tina said:

Thanks again Nuoyan

# December 31, 2007 9:02 AM

Christine said:

How do i enable a disabled service using this command?

# March 25, 2008 2:08 AM

AOOMMEN said:

Can you tell me how to delete a service form windows 2003 server, I tried sc delete command, but it does not work.  

The server name in not just one word, it is like this

SQL Server (CSA)

SQL Server Analysis Services (CSA)

I am not able to delete these. can you help

thanks

# May 1, 2008 9:46 AM

AOOMMEN said:

My email is aoommen77@yahoo.com, I asked for help in deleting windows service that has more than one word. for example

SQL Server Analysis Services (CSA)

Thanks.

# May 1, 2008 9:49 AM

chris dolese said:

also looking for assitance on how to delete those services where the service name is made up of more than one word ???

thanks

# May 12, 2008 2:55 PM

Pankaj Kathar said:

Thanks a lot !!!

sc delete "service_name"

Worked for me... :)

# May 30, 2008 4:21 AM

Brad Shoap said:

Thanx you for the post on use of SC to delete a service.  Your universal engergy is good!

PEACE

# June 3, 2008 8:55 AM

Horace Miles said:

Thank you for the information on how to delete a service without having to edit the registry. Good information.

Miles

# July 25, 2008 12:10 PM

Saurabh Deshpande said:

Thanks Guys,

After going through your conversation

I found my solution

Thanks very Much

Saurabh

# September 23, 2008 2:06 PM

Bishakha Sinha said:

Hi Guys,

There is one easy command for deleting Services in Windows Server 2003.

Instsrv <ServiceName> Remove

Hope it Helps !!

Thanks Much,

Bishakha

# November 7, 2008 10:25 AM

MaestroDabla said:

Thank you for the information on how to delete a service without having to edit the registry. Good information.

# November 26, 2008 10:12 AM

Tom said:

You need to find the actual service name first, then you can do the delete command. If the service is inactive, you can't use the state= all, which doesn't show inactive services. Also, since the services list is so long, you need to "pipe" it to a text file. Here is how:

From command prompt:

sc query state= inactive >services.txt

Find the service name from services.txt, then:

sc \\servername delete servicename

# December 8, 2008 10:53 AM

Anonymous said:

Also an easier way to get the service name is to open the services administrative tool and then open the service.  At the very top is the actual name of the service along with the display name below it.  You need the actual name to delete the service.  

Hope this helps you out.

# December 22, 2008 6:08 PM

How to delete a service in Windows Server 2003 | Easy Read Articles said:

Pingback from  How to delete a service in Windows Server 2003 | Easy Read Articles

# June 15, 2009 12:48 AM

Dennis Hartmann said:

Hi guys,

just tried to get rid of sqlwiter service. Tried uninstalling it first in add/remove - gave me fatal error during uninstall. Used sc delete sqlwiter - no dice.

Service was in a "starting" state after that but also says "disabled". Can't get rid of it, nor can I start or successfully stop the service. Any ideas???

# December 8, 2009 12:04 PM

Shishir said:

When I reinstalled my service, Since I forgot to stop the service I am getting this error message:

"The specified service has been marked for deletion"

According to msdn, we can reboot the machine to resolve this issue.

But, is there any other way to do this w/o restarting the machine.

# December 9, 2009 2:41 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)