asp.net windows services

  • Thread starter Thread starter Guest
  • Start date Start date
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 ?
 
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 ?
 
Back
Top