i have created installer for windows service and from AfterInstall
event i am starting service but before start the service i like to check if service is not running then i will start the service otherwise not but i do not know how to check my service is running or not from AfterInstall
event. please guide. thanks
using System.ServiceProcess;
class ServInstaller : ServiceInstaller
{
void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
{
using (ServiceController sc = new ServiceController(serviceInstaller1.ServiceName))
{
sc.Start();
}
}
}