int SCMStartService(string servername, string
Returns OK if succeeded or FAIL if error occurred..
servername – string that
specifies the Universal Naming Convention (UNC) name or IP address
of the target computer on which the service control manager is to
be opened. If this parameter is "localhost", the operation is
performed on the local computer.
servicename - the name of the service to
start. Note that this is not a Display
Name of the service as it appears in Control Panel. Service Name
can be retrieved by SCMGetServiceInfo function.
When connecting to
the service control manager on remote computer it is required that a user that executes
this function on local computer is logged in using an account
(usually local domain account) which at the same time has
administrative permissions on remote computer. In other words if
user Bob executes SCMStartServicefunction on computer A and specifies
servername of computer B, user Bob must be an
administrator of computer B as well.
When a driver service is
started, the SCMStartServicefunction does not return until
the device driver has finished initializing.
When a service is started, the Service Control Manager (SCM) spawns
the service process, if necessary. If the specified service shares
a process with other services, the required process may already
exist. The SCMStartServicefunction does not wait for the
first status update from the new service, because it can take a
while. Instead, it returns when the SCM receives notification from
the service control dispatcher that the thread for this service was
Plug in module:
The following example demonstrates the use of
# Example for SCMStartService
string sHostName = "localhost"
string sMonitoredServiceName = "NetDecision Service Manager"
int nNumberOfServices = SCMEnumerateServices(sHostName)
if(nNumberOfServices == FAIL)
Println("Error retrieving services: ", GetSystemErrorString(GetLastSystemError()))
Println("Retrieved ", nNumberOfServices, " services")
for(int i = 0; i < nNumberOfServices; i++)
= SCMGetServiceInfo(sHostName, i)
# Check if this is service we are looking
if(sServiceName == sMonitoredServiceName)
Println("Found ", sMonitoredServiceName, " - service is ", ServiceInfo["State"])
# Check if service is running and start it if
if(ServiceInfo["State"] == "STOPPED")
nStatus = SCMStartService(sHostName, ServiceInfo["Name"])
if(nStatus == OK)
Println(sMonitoredServiceName, " successfuly started")
Println("Failed to start ", sMonitoredServiceName)
Output of the example
Found NetDecision Service Manager - service is