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
  • 17,317
  • 32
  • 140
  • 246

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
  • 44,454
  • 10
  • 85
  • 129
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,751
  • 3
  • 28
  • 30