start a windows service remotely

G

graphicsxp

Hi,
I've written a windows service in vb.net, which works very well. The
service is installed on my server, but now I would like to be able to
start/stop it from any machine on the network.

I know the command sc.exe but unfortunately it does not prompt for
Username/Password, and those are required otherwise I'll always get the
message 'Access denied'. Unless I can bypass authentication to start a
windows service ?

Can you help ?

thanks
 
G

Guest

Hi,
I've written a windows service in vb.net, which works very well. The
service is installed on my server, but now I would like to be able to
start/stop it from any machine on the network.

I know the command sc.exe but unfortunately it does not prompt for
Username/Password, and those are required otherwise I'll always get the
message 'Access denied'. Unless I can bypass authentication to start a
windows service ?


You can use the ServiceController class in .NET to start/stop services
remotely.

Or you can do it via WMI.

Or you could build a remoting interface.

So there are several ways to do it :)
 
G

graphicsxp

Hi,
Thank you for your reply.
Actually I've started using ServiceController class. However I can't
even access a service on my own machine... Here's what I do:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ServiceController1.Start()
End Sub

and

Me.ServiceController1.MachineName = "seoul"
Me.ServiceController1.ServiceName = "SMemory"

The error message I get is : Cannot start service SMemory on computer
'seoul'.
Any idea what I'm doing wrong ?
 
P

Phill W.

graphicsxp said:
I know the command sc.exe but unfortunately it does not prompt for
Username/Password

What makes you think that it should?

Your service should be configured to always run under a given account so
you shouldn't need to provide username/password every time you start the
service.

Or is that you're trying to /configure/ these settings (using sc)?
IIRC, the "obj= " and "password= " options are the ones you need.

HTH,
Phill W.
 
G

graphicsxp

hummm.... Well I gave up on using sc. And I wrote my own tool using
ServiceProcess to access the windows service and impersonation to get
granted user rights. It works great now.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top