asp.net windows services

G

Guest

I need to create a asp.net page that will have the ability to start and stop and windows service that we have created. Is there an api or something that I can use to interact with windows services ?
 
M

Martin Dechev

Hi, jzink,

I posted this yesterday to a similar topic:

I think you will need to impersonate a user that has rights to
start/stop services on the machine (I'm afraid I can't give you the list of
these rights)

Have a look at the following article:
[ Implementing Impersonation in an ASP.NET Application ]
http://support.microsoft.com/default.aspx?kbid=306158

After doing so, you have 2 ways
- using the System.Diagnostics.Process to start "net.exe" and passing it the
appropriate parameters. It's simpler, but not the better way for sure.
- using platform-invoke - you will have to call the following functions:
http://msdn.microsoft.com/library/en-us/dllproc/base/openscmanager.asp
http://msdn.microsoft.com/library/en-us/dllproc/base/openservice.asp
http://msdn.microsoft.com/library/en-us/dllproc/base/startservice.asp
(optionally, if you need to further control the service, i.e. stop it:)
http://msdn.microsoft.com/library/en-us/dllproc/base/controlservice.asp
http://msdn.microsoft.com/library/en-us/dllproc/base/closeservicehandle.asp

Hope this helps
Martin

jzink said:
I need to create a asp.net page that will have the ability to start and
stop and windows service that we have created. Is there an api or something
that I can use to interact with windows services ?
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top