Service_GetState
Description
Section titled “Description”Gets the current state of the specified service.
Syntax
Section titled “Syntax”Service_GetState(sServiceName) As Boolean
Parameters
Section titled “Parameters”sServiceName (String)
Section titled “sServiceName (String)”Name of the service. Use the service name, for example Spooler, not the display name.
Return value
Section titled “Return value”Result will be stored in gsValue, as Windows reports it: Running, Stopped, Paused, Start Pending, Stop Pending, Continue Pending, Pause Pending or Unknown.
Running, Stopped and Paused match the Service Controller Status constants SCS_Running, SCS_Stopped and SCS_Paused. The pending states contain a space, so compare them with the text, for example "Start Pending", not with the SCS constants.
The function returns False if the service doesn’t exist.
Example
Section titled “Example”If bStatus Then bStatus = Service_GetState("Service")If bStatus Then bStatus = Job_WriteLog("Custom", "gsValue: " & gsValue, bStatus, True)Related functions
Section titled “Related functions”Service_Exist Service_SetLogonInformations Constants Package Property Variables