1

I need to check and see if the "Server" service is running. Easy enough, using a method like this: How can I verify if a Windows Service is running

The problem comes in when the OS installation is not English. For example on a Windows installation, the "Server" service is known as "Serveur". Obviously I don't want to hardcode separate languages into my app. Anyone have any good ideas for doing this cleanly?

Community
  • 1
  • 1
Kyle
  • 16,774
  • 30
  • 128
  • 237

2 Answers2

2

Test out the following code and see what results you get, you may be surprised...

using System.ServiceProcess;

var controller = new ServiceController("LanmanServer");

Console.WriteLine(controller.ServiceName); // <- this is the unique name

Console.WriteLine(controller.DisplayName); // <- this is subject to change
Grant Thomas
  • 43,307
  • 9
  • 83
  • 125
1

Like the others, I suspect that the service name doesn't change across languages. It's usually the display name that changes.

Fun Mun Pieng
  • 6,501
  • 3
  • 27
  • 29