Installs a windows service.

CreateService(cServiceName, cDisplayName, cExecutable [, nServiceType [, nStartType [, nErrorControl [, cLoadOrderGroup [, cDependencies [, cServiceAccount [, cAccountPassword [, cMachine [, cDatabase]]]]]]]]])

Parameters

cServiceName

The short name of the service.

cDisplayName

The descriptive name of the service.

cExecutable

Full path to the service executable.

nServiceType (optional)

default = SERVICE_WIN32_OWN_PROCESS

The service type.

This parameter can be one of the following values.
Service typeDescription
SERVICE_FILE_SYSTEM_DRIVERFile system driver service.
SERVICE_KERNEL_DRIVERDriver service.
SERVICE_WIN32_OWN_PROCESSService that runs in its own process.
SERVICE_WIN32_SHARE_PROCESSService that shares a process with one or more other services.
SERVICE_INTERACTIVE_PROCESSIf you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, you can also specify this value.
nStartType (optional)

default = SERVICE_AUTO_START

The service start options.

This parameter can be one of the following values.
Start typeDescription
SERVICE_AUTO_STARTA service started automatically by the service control manager during system startup.
SERVICE_BOOT_STARTA device driver started by the system loader. This value is valid only for driver services.
SERVICE_DEMAND_STARTA service started by the service control manager when a process calls the StartService function.
SERVICE_DISABLEDA service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED.
SERVICE_SYSTEM_STARTA device driver started by the IoInitSystem function. This value is valid only for driver services.
nErrorControl

default = SERVICE_ERROR_NORMAL

The severity of the error, and action taken, if this service fails to start.

This parameter can be one of the following values.
Error controlDescription
SERVICE_ERROR_CRITICALThe startup program logs the error in the event log, if possible. If the last-known-good configuration is being started, the startup operation fails. Otherwise, the system is restarted with the last-known good configuration.
SERVICE_ERROR_IGNOREThe startup program ignores the error and continues the startup operation.
SERVICE_ERROR_NORMALThe startup program logs the error in the event log but continues the startup operation.
SERVICE_ERROR_SEVEREThe startup program logs the error in the event log. If the last-known-good configuration is being started, the startup operation continues. Otherwise, the system is restarted with the last-known-good configuration.
cLoadOrderGroup (optional)

default = NULL

cDependencies (optional)

cServiceAccount (optional)

cAccountPassword (optional)

cMachine (optional)

cDatabase (optional)

Return Value

Always .T.

See Also

Reference

ADependentServices
AServiceConfig
AServices
AServiceStatus
CloseServiceHandle
ContinueService
ControlService
OpenService
PauseService
StartService
StopService
WaitForServiceStatus

Used WinApi functions

OpenSCManager
CreateService
CloseServiceHandle