-1

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
  • 9,653
  • 3
  • 20
  • 28
Diego
  • 1,686
  • 3
  • 23
  • 47
  • 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

3

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
  • 1,686
  • 3
  • 23
  • 47