RE: Check if Service Exists?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"=?Utf-8?B?RGFycmVsbCBXZXNsZXk=?="
<DarrellWesley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:5FF845E6-2CF6-474B-938B-B0288CB20A7F@xxxxxxxxxxxxx:

> DOn't know if this the correct way or not but it's what one of our
> programs is doing to see if a Service is installed.
>
> '
> ' Check to see if VNC is installed
> '
> Dim scServices() = ServiceController.GetServices()
> Dim i As Integer = 0
>
> While i < scServices.Length
> 'MessageBox.Show(scServices(i).DisplayName)
> If scServices(i).DisplayName = "VNC Server" Then
> m_bVNC = True
> End If
> i = i + 1
> End While

Thank you - I was hoping to avoid looping through all my services. I was
sort of expecting that .NET would throw an error if it tried to create
an non-existing service.

i.e. New ServiceController("NoSuchService")

But it doesn't.

In anycase, the GetServices method way will work just fine for me.

Thank you : )


--
Lucas Tam (REMOVEnntp@xxxxxxxxxx)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
.



Relevant Pages

  • Re: Number of connections
    ... Take a look at the events in the global.asax, you can flag a user in there. ... Lucas Tam ... Please delete "REMOVE" from the e-mail address when replying. ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Login - return back to original page
    ... ASP.NEt's Forms authentication handles URL redirection for you. ... Lucas Tam ... Please delete "REMOVE" from the e-mail address when replying. ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to show a confirm box with Button Click
    ... Lucas Tam ... Please delete "REMOVE" from the e-mail address when replying. ... Newmarket Volvo Sucks! ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: mySql vs. sql server in asp.net hoster
    ... > is MySQL Cluster Server for 99.9999% fault tolerence. ... Lucas Tam ... Please delete "REMOVE" from the e-mail address when replying. ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Raise event inside a thread
    ... using monitors or a ManualResetEvent. ... Jon Skeet - ... If replying to the group, please do not mail me too ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)