Home All Groups Group Topic Archive Search About

start a windows service remotely

Author
1 Nov 2006 1:47 PM
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

Author
1 Nov 2006 2:10 PM
Spam Catcher
"graphicsxp" <samuelberthe***@googlemail.com> wrote in
news:1162388835.159321.184730@i42g2000cwa.googlegroups.com:

> 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 :)
Author
1 Nov 2006 2:32 PM
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 ?

Spam Catcher wrote:
Show quoteHide quote
> "graphicsxp" <samuelberthe***@googlemail.com> wrote in
> news:1162388835.159321.184730@i42g2000cwa.googlegroups.com:
>
> > 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 :)
Author
1 Nov 2006 2:47 PM
Phill W.
graphicsxp wrote:

> 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.
Author
1 Nov 2006 5:27 PM
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

Phill W. wrote:
Show quoteHide quote
> graphicsxp wrote:
>
> > 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.