ServiceController::Start Method ()


Starts the service, passing no arguments.

Namespace:   System.ServiceProcess
Assembly:  System.ServiceProcess (in System.ServiceProcess.dll)

void Start()

Exception Condition

An error occurred when accessing a system API.


The service was not found.

You cannot call Stop for the service until the service controller status is Running.

The following example uses the ServiceController class to check whether the Alerter service is stopped. If the service is stopped, the example starts the service and waits until the service status is set to Running.

// Check whether the Alerter service is started.
ServiceController^ sc = gcnew ServiceController;
if ( sc )
   sc->ServiceName =  "Alerter";
   Console::WriteLine(  "The Alerter service status is currently set to {0}", sc->Status );
   if ( sc->Status == (ServiceControllerStatus::Stopped) )
      // Start the service if the current status is stopped.
      Console::WriteLine(  "Starting the Alerter service..." );
         // Start the service, and wait until its status is "Running".
         sc->WaitForStatus( ServiceControllerStatus::Running );

         // Display the current service status.
         Console::WriteLine(  "The Alerter service status is now set to {0}.", sc->Status );
      catch ( InvalidOperationException^ e ) 
         Console::WriteLine(  "Could not start the Alerter service." );


for controlling services on the computer. Associated enumeration: ServiceControllerPermissionAccess::Control


for unrestricted access to service information. Associated enumeration: PermissionState::Unrestricted

.NET Framework
Available since 1.1
Return to top