Sometimes you want to detect whether a service is running, and if not, you want to run it. Here is what you can do for the Sql Server Agent Service:
EXEC master.dbo.xp_ServiceControl 'QUERYSTATE','SQLServerAgent'
EXEC master.dbo.xp_ServiceControl 'START', 'SQLServerAgent'
But, xp_ServiceControl is undocumented and unsupported; its behavior could change with a service pack or the next release of SQL Server. So now I am looking for some better solutions....
If you know, please tell me.