The winservices class, subclassed from the Collection class, enumerates Windows Services found in the default service control manager database on local computer.
Each item in the collection is an instance of the winservice class that wraps the members of ENUM_SERVICE_STATUS structure for a given service. The winservice object exposes methods StartService, StopService and PauseService.
Here is an example of how these classes can be used to start/stop the MSSQLSERVER service on local computer:
#DEFINE SERVICE_WIN32 0x30
#DEFINE SERVICE_RUNNING 4
LOCAL ws As winservices, srv As winservice
ws = CREATEOBJECT("winservices", Null, Null, SERVICE_WIN32)
srv = ws.GetService("MSSQLSERVER")
IF ISNULL(srv)
? "MSSQLSERVER service is not found on this computer"
ELSE
? "MSSQLSERVER service is " +;
IIF(srv.currentstate=SERVICE_RUNNING,;
"running", "stopped") + "."
ENDIF
srv.StartService()
*srv.PauseService()
*srv.StopService()
|