0

I am doing a C# Net Core 2.0 Application. I need to execute a Windows Service, but before I need to check if it is running.

I saw in this post that the best way is using ServiceController like this

try
{
    using( ServiceController sc = new ServiceController( SERVICE_NAME ) )
    {
        return sc.Status == ServiceControllerStatus.Running;
    }
}

But I do not find it in Net core 2.0

How can I checked it ?

maccettura
  • 10,514
  • 3
  • 28
  • 35
Diego
  • 2,238
  • 4
  • 31
  • 68
  • Almost all "extra" libraries are added via Nuget in .NET Core. If you bothered to google this you would see. – maccettura Mar 05 '18 at 20:23

1 Answers1

5

For those who are new in Net Core 2.0.. here is the answer..

In Nuget Console Mode... write

PM>  Install-Package System.ServiceProcess.ServiceController -Version 4.4.1 
Diego
  • 2,238
  • 4
  • 31
  • 68