0

Colleagues, I have a client-server application. Within the server, I've created a Windows service that uses an ODBC connection via a DSN.

Sometimes when I check the server, I see that the Windows service is stopped.

How can I check this Windows service from my client application so it can be started?

I have this code in Vb.Net, but it only works locally on the server.

Dim sc As New ServiceController("ServicioBD")
If sc.Status = ServiceControllerStatus.Running Then
   MessageBox.Show("Service Running" + sc.ServiceName)
Else
   MessageBox.Show("Service Not Running" + sc.ServiceName)
End If
sc.Dispose()

I would greatly appreciate any help you can give me.

3
  • 1
    There's a ServiceController constructor overload that allows to specify the machine's name Commented Oct 22 at 17:07
  • are you running against the same account even though its the other server Commented Oct 25 at 1:30
  • 3
    Maybe a bit late in the piece, what you’re looking to do here is adding robustness to your app. That said have you looked at the reasons why the service is stopping? This approach could just be putting a bandage over a symptom of a much bigger issue Commented Oct 27 at 19:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.