Solved

Windows Service ServiceController in VB.NET error

Posted on 2011-03-03
3
1,377 Views
Last Modified: 2012-08-14
I have created a windows service and have successfully installed it and confirmed it works.

Now I am trying to connect to it using a ServiceController from System.ServiceProcess.

I am not able to view information about my service, but I can view information from other services on the server... so I did not think it would be a network permission issue.

I get this error message:  "Cannot open DbaseEmailService service on computer 'ServerName'.
I get this InnerExeception Message:  "Access is denied"

I must have missed something when creating the service,  Is there some property I may need to set on my service app that will allow me to control it using the ServiceController in VB.NET?
Dim se As System.ServiceProcess.ServiceController

Try
             se = New System.ServiceProcess.ServiceController("DbaseEmailService", "ServerName") 'DOES NOT WORK
             
            ' se = New System.ServiceProcess.ServiceController("Alerter", "ServerName") 'WORKS OK


            ' se = New System.ServiceProcess.ServiceController("Dnscache", "ServerName") 'WORKS OK

        Dim bt As String = "Service Status Unknown"
        'display service status

        Select Case se.Status
            Case ServiceProcess.ServiceControllerStatus.Stopped
                bt = "Service Stopped"
                Case ServiceProcess.ServiceControllerStatus.Running
                    bt = "Service Running"
                Case Else

            End Select
            ButtonService.Content = bt

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

Open in new window

0
Comment
Question by:handyjay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
lenordiste earned 500 total points
ID: 35032116
well, it does look like a permission issue. What account is your service running as ? is it the same as the other services you are able to query?

in any case you might want to look at this information:
http://craig.dubculture.co.nz/blog/2007/12/07/querying-the-status-of-a-windows-service/
0
 

Author Comment

by:handyjay
ID: 35036550
The service is running under account:  NT AUTHORITY\NetworkService

Everything else seems correct when comparing against other services that work.

The only difference was the Path to executable was different, so I made sure permissions were set the same as the others that work, but still have access denied.

0
 

Author Closing Comment

by:handyjay
ID: 35192225
Only answer I got... still not working
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question