Monday, June 12, 2006

Interacting with NT Service via Console

What is Windows Service?
Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. This makes services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer.


How to interact with Windows Service or NT Service?

Normally the interaction to the service done through the service console, which can be started by giving "services.msc" in the RUN option on windows.

Console?

We can also do the same set of operations like starting, stoping, creating, pausing etc., through console using "sc" command.
SC is a command line program used for communicating with theNT Service Controller and services.

How?

Open the command prompt and type "sc" you can see list of options you can use with sc command.
Exmaple

sc start "service name" --> Starts a service given by "service name"
sc pause "service name" --> Sends a PAUSE control request to a service given by "service name"
sc continue "service name" --> Sends a CONTINUE control request to a service given by "service name"
sc stop "service name" --> Sends a STOP request to a service given by "service name"
sc delete "service name" --> Deletes the service given by "service name"

When it is useful?
1) When your associated service executable is no more available or it is giving error, then uninstalling service is a problem, so we can use "sc" command to delete the service manually from the console.
2) When the service is not responding with uninstalling, we can delete through the console.
3) We can start the service from console may through the batch (.bat) file.
4) To query the status of the service from the console

What else?

We can use the "sc" command to get the status of particular service, or enumerates the status for types of services.
If the query command is followed by a service name, the status for that service is returned. Further options do not apply in this case. If the query command is followed by nothing or one of the options listed below, the services are enumerated.
type= Type of services to enumerate (driver, service, all)(default = service)

state= State of services to enumerate (inactive, all)(default = active)

bufsize= The size (in bytes) of the enumeration buffer (default = 4096)

SYNTAX EXAMPLES

sc query - Enumerates status for active services & drivers

sc query type= driver - Enumerates only active drivers

sc query type= service - Enumerates only Win32 services

sc query state= all - Enumerates all services & drivers

sc query type= driver group= NDIS - Enumerates all NDIS drivers


Where? To get more information about this go to console and type "sc"

Deleting service --> "http://www.tweakxp.com/tweak1976.aspx"

0 Comments:

Post a Comment

<< Home