Represents a Windows service and allows you to connect to a running or stopped service, manipulate it, or get information about it.
Assembly: System.ServiceProcess (in System.ServiceProcess.dll)
Initializes a new instance of theclass that is not associated with a specific service.
Initializes a new instance of theclass that is associated with an existing service on the local computer.
Initializes a new instance of theclass that is associated with an existing service on the specified computer.
Gets a value indicating whether the service can be paused and resumed.
Gets a value indicating whether the component can raise an event.(Inherited from Component.)
Gets a value indicating whether the service should be notified when the system is shutting down.
Gets a value indicating whether the service can be stopped after it has started.
Gets the set of services that depends on the service associated with thisinstance.
Gets or sets a friendly name for the service.
Gets or sets the name of the computer on which this service resides.
Gets the handle for the service.
Gets or sets the name that identifies the service that this instance references.
The set of services that this service depends on.
Gets the type of service that this object references.
Gets a value that indicates how the service represented by theobject starts.
Gets the status of the service that is referenced by this instance.
Disconnects thisinstance from the service and frees all the resources that the instance allocated.
Continues a service after it has been paused.
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)
Releases the unmanaged resources used by the Component.Dispose(Boolean).)and optionally releases the managed resources. (Overrides
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Executes a custom command on the service.
Retrieves the device driver services on the local computer.
Retrieves the device driver services on the specified computer.
Serves as the default hash function. (Inherited from Object.)
Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)
Retrieves all the services on the local computer, except for the device driver services.
Retrieves all the services on the specified computer, except for the device driver services.
Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)
Suspends a service's operation.
Refreshes property values by resetting the properties to their current values.
Starts the service, passing no arguments.
Starts a service, passing the specified arguments.
Stops this service and any services that are dependent on this service.
Infinitely waits for the service to reach the specified status.
Waits for the service to reach the specified status or for the specified time-out to expire.
You can use theclass to connect to and control the behavior of existing services. When you create an instance of the class, you set its properties so it interacts with a specific Windows service. You can then use the class to start, stop, and otherwise manipulate the service.
You will most likely use thecomponent in an administrative capacity. For example, you could create a Windows or Web application that sends custom commands to a service through the instance. This would be useful, because the Service Control Manager (SCM) Microsoft Management Console snap-in does not support custom commands.
After you create an instance of, you must set two properties on it to identify the service with which it interacts: the computer name and the name of the service you want to control.
By default, MachineName is set to the local computer, so you do not need to change it unless you want to set the instance to point to another computer.
Generally, the service author writes code that customizes the action associated with a specific command. For example, a service can contain code to respond to an ServiceBase.OnPause command. In that case, the custom processing for the Pause task runs before the system pauses the service.
The set of commands a service can process depends on its properties; for example, you can set the CanStop property for a service to false. This setting renders the Stop command unavailable on that particular service; it prevents you from stopping the service from the SCM by disabling the necessary button. If you try to stop the service from your code, the system raises an error and displays the error message "Failed to stop servicename."
Available since 10
Available since 1.1
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.