Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Start/Stop a service using asp.net

Hi,

I've been struggling with trying to start/stop a service using asp.net.

Basically I just want a button that stops/starts a service, embedded on a web page.

These service is actually an application that was turned into a service using srvany.exe; its purpose is to control some custom hardware. Without going into too much detail, basically think graduate student monitoring some experiment from home and being able to turn the hardware on or off.

Obviously there are some security restrictions to consider, but at the present there is no concern for that.

If anybody has an idea, please let me know... I've been struggling with it for a while.

Thanks in advance.

Lindy
Friday, June 18, 2004

What is it you don't get? How to start and stop a service? Or how to take functional code that can start and stop a service, and make it work in the context of an ASP.NET application?

Brad Wilson (dotnetguy.techieswithcats.com)
Friday, June 18, 2004

I'm getting some "Access Denied" messages. I don't have access to the machine right now, or I would copy it here. For some reason the code doesn't work when it's embedded in a webpage. It does work in a stand-alone application.

IIS is running on that machine so that it can serve up aspx pages from outside the LAN.

I'll try to provide more info later, but it seems to be some sort of security restriction...

Lindy
Friday, June 18, 2004

> How to start and stop a service? Or how to take functional code that can start and stop a service, and make it work in the context of an ASP.NET application?

If you know of an example of this, I would very much appreciate a link.

I'm just a beginner at this. :)

Thanks!

Lindy
Friday, June 18, 2004

what account is the asp.net service running under? are you using delegation? is it on the same machine as the service?

basically asp.net pages run under a restricted account for obvious reasons. one standard mechanism to ensure privildges is to use windows integrated authentication and impersonate the calling user.

mb
Saturday, June 19, 2004

Lindy,

Have you looked into using WMI? With WMI, you can stop and start services with ASP.NET.

One caveat is that the default ASP.NET account (ASPNET) doesn't have the permissions to stop and start a service.  Here are couple of ideas for a workaround:

1. Give ASPNET the permissions to do this. Probably not a great idea.
2. Have ASP.NET run under higher privileged account. Again, not a great idea.
3. Have the code that calls the WMI impersonate a privileged account that has permission.

Any time you're doing anything with ASP.NET that requires elevating it's permissions there are a lot of security considerations to think through; but that's a whole other exercise. :')

Mark Hoffman
Wednesday, June 23, 2004

"What is it you don't get? How to start and stop a service? Or how to take functional code that can start and stop a service, and make it work in the context of an ASP.NET application? "

What the fuck do you think he is asking, Brad?! Do you think that he came to a .NET board to ask how to start and stop a fucking service?

Is the title of his question too fucking hard for you to understand? Read it. See what it says? Dipshit. Your'e such a little arrogant prick.

Good grief
Wednesday, June 23, 2004

Hi Mark,

Thanks for your advice. I've got enough to go on now!

Lindy
Friday, July 09, 2004

lindy
am also facing a similiar problem like what you have mentioned.

can yu let me know what the steps you have come across to start/stop services from ASP.net??

SenthilVel
Tuesday, August 10, 2004

hi all
i just used Impersonataion and now am able to get access to my windows services.

,,,,
Senthil

SenthilVel
Friday, August 13, 2004

*  Recent Topics

*  Fog Creek Home