467,920 Members | 1,236 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

Service name

Hi,

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

Thanks,

Lubomir
Sep 14 '07 #1
  • viewed: 4817
Share:
6 Replies
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:D7**********************************@microsof t.com...
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.
Sep 15 '07 #2
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

"Alberto Poblacion" wrote:
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:D7**********************************@microsof t.com...
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.
Sep 16 '07 #3
On Sep 14, 4:56 pm, Lubomir <Lubo...@discussions.microsoft.comwrote:
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).

Sep 16 '07 #4
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:92**********************************@microsof t.com...
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.
Sep 16 '07 #5
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:92**********************************@microsof t.com...
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.NetworkService Sid, 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?

Sep 16 '07 #6
Thanks for help.

Lubomir

"Doug Semler" wrote:
"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:92**********************************@microsof t.com...
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.NetworkService Sid, 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?

Sep 17 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by PatrickSA | last post: by
9 posts views Thread by Hardy Wang | last post: by
3 posts views Thread by Jeremy S. | last post: by
3 posts views Thread by Jerome Cohen | last post: by
4 posts views Thread by tshad | last post: by
dmjpro
3 posts views Thread by dmjpro | last post: by
20 posts views Thread by =?Utf-8?B?cmtibmFpcg==?= | last post: by
5 posts views Thread by dm3281 | last post: by
reply views Thread by =?ISO-8859-1?Q?Jan_Thom=E4?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.