Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

Service name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lubomir - 14 Sep 2007 21:56 GMT
Hi,

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

Thanks,

Lubomir
Alberto Poblacion - 15 Sep 2007 07:52 GMT
> 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.
Lubomir - 16 Sep 2007 20:18 GMT
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

> > I would like to ask how can I with C# find out the service name on
> > non-English Windows OS.
[quoted text clipped - 4 lines]
> DisplayName is the one that should be localized for different language
> versions.
Alberto Poblacion - 16 Sep 2007 20:36 GMT
> 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
[quoted text clipped - 5 lines]
> 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.
Doug Semler - 16 Sep 2007 21:10 GMT
> Thanks fro answer.
>
[quoted text clipped - 15 lines]
> 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.

Signature

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?

Lubomir - 17 Sep 2007 22:42 GMT
Thanks for help.

Lubomir

> > Thanks fro answer.
> >
[quoted text clipped - 38 lines]
> 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.
Arnshea - 16 Sep 2007 20:34 GMT
> Hi,
>
[quoted text clipped - 4 lines]
>
> 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).

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.