Service name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I would like to ask how can I with C# find out the service name on
non-English Windows OS.

Thanks,

Lubomir
 
Lubomir said:
I would like to ask how can I with C# find out the service name on
non-English Windows OS.

ServiceController.GetServices() returns an array of ServiceController
objects that represent all the services running in the computer.
Each ServiceControler has the properties ServiceName and a DisplayName.
DisplayName is the one that should be localized for different language
versions.
 
Thanks fro answer.

My problem is, that I need to find some particular service. For exmaple I
need to work with "Network Service" and I need to pass its name to some
function.

If U run a non English version of OS, the name if this service will not be
"Network Service". So when I use the method you recommended, I gte a list of
non-english names. How I will know, which one of them is "Network Service" ?

I think I should be able to find any particular service by his SID. This SID
I guess is the same on all Windows OS. So using this SID I would get the
"Network Service" name is the particular localized language.

I don't know how to work with SIDs in C#. I didn't find any methods that
would use it for returning a service name.

Regards,

Lubomir
 
Hi,

I would like to ask how can I with C# find out the service name on
non-English Windows OS.

Thanks,

Lubomir

You may be able to use WMI - select * from Win32_Service then check
the pathname? (assuming this doesn't vary from language to language).
 
Lubomir said:
My problem is, that I need to find some particular service. For exmaple I
need to work with "Network Service" and I need to pass its name to some
function.

If U run a non English version of OS, the name if this service will not be
"Network Service". So when I use the method you recommended, I gte a list
of
non-english names. How I will know, which one of them is "Network Service"
?

The idea is that you have the two properties ServiceName and a DisplayName.
While DisplayName is different in different languages, ServiceName is not.
ServiceName is supposed to be the same in all the versions of the OS.
 
Lubomir said:
Thanks fro answer.

My problem is, that I need to find some particular service. For exmaple I
need to work with "Network Service" and I need to pass its name to some
function.

If U run a non English version of OS, the name if this service will not be
"Network Service". So when I use the method you recommended, I gte a list
of
non-english names. How I will know, which one of them is "Network Service"
?

I think I should be able to find any particular service by his SID. This
SID
I guess is the same on all Windows OS. So using this SID I would get the
"Network Service" name is the particular localized language.

I don't know how to work with SIDs in C#. I didn't find any methods that
would use it for returning a service name.

Network Service is a windows account name, not a service name. Services are
"background processes" that have a non localized "Service Name" and a
localized "Display Name".

When looking for services, you use the "Service Name" because that does not
change across different localizations. However, the Display Name can be
(not necessarily is) different accross the different localizations.

That being said, if you want to get the "name" of the Network Service
account, you could do something like
using System.Security.Principal;
....

SecurityIdentifier id = new
SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null);
NTAccount acct = (NTAccount)id.Translate(typeof(NTAccount);
string networkServiceAccountName = acct.Value;

I don't know if that final result is localized or not (I cannot remember
offhand). However, the first line creates the SID representation of the
account. I don't know what you'd want to do with this particular account
name, since you originally asked about finding services, not accounts.

--
Doug Semler, MCPD
a.a. #705, BAAWA. EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?
 
Thanks for help.

Lubomir



Doug Semler said:
Network Service is a windows account name, not a service name. Services are
"background processes" that have a non localized "Service Name" and a
localized "Display Name".

When looking for services, you use the "Service Name" because that does not
change across different localizations. However, the Display Name can be
(not necessarily is) different accross the different localizations.

That being said, if you want to get the "name" of the Network Service
account, you could do something like
using System.Security.Principal;
....

SecurityIdentifier id = new
SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null);
NTAccount acct = (NTAccount)id.Translate(typeof(NTAccount);
string networkServiceAccountName = acct.Value;

I don't know if that final result is localized or not (I cannot remember
offhand). However, the first line creates the SID representation of the
account. I don't know what you'd want to do with this particular account
name, since you originally asked about finding services, not accounts.

--
Doug Semler, MCPD
a.a. #705, BAAWA. EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Mark file for deletion 3
64 bit OS 2
Arraylist deep copy 2
Visual C++ 7.0 and C#.NET 1
Interactive windows service 3
Exception handling 7
Get object from string 4
Charts, diagrams 4

Back
Top