Re: System.Diagnostic.Process and disfunctional process

From: Martin Dechev (detcheff__at_hotmail.com)
Date: 02/17/04


Date: Tue, 17 Feb 2004 13:46:26 +0100

Hi, Michael Johnson Sr.,

I think you will still 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 (the last section in it):
[ 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 call "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
"Michael Johnson Sr." <m.johnson.sr@acmewidgets.com> wrote in message
news:e03$uCU9DHA.2316@TK2MSFTNGP09.phx.gbl...
> I am starting and stopping a process using System.Diagnostic.Process.
>
> aspnet_wp is running as system rather than machine (as per machine.config
> modification). When the process gets started, it will not respond to tcp
> connections. The process is a service that accepts incoming tcp
> connections.
>
> Any ideas will be great.
>
>



Relevant Pages

  • MOSS 2007 - Changing ListItem permissions in EventReciever
    ... Feature registrates FeatureEventReciever ... ItemAdded event changes access rights of item that was created to ... So I need to impersonate programmatically Admin user. ... bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Losing Shared Network Printer Connection
    ... Verify the number of connections on the machine sharing the printer. ... Windows Printing Team ... This posting is provided "AS IS" with no warranties, and confers no rights. ... All other network resources are accessible. ...
    (microsoft.public.windowsxp.print_fax)
  • Re: XP Network setup wizard will not start
    ... >> confers no rights. ...
    (microsoft.public.windowsxp.network_web)
  • Re: System.Security.Principal.WindowsImpersonation
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... >>' This sample can be run only on Windows XP. ... >>' proper execution presents a security risk. ... >>impersonate a user on this machine. ...
    (microsoft.public.dotnet.security)
  • Re: ASP error for CreateObject
    ... This sounds as if you're running out of connections. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... > when i try to upload a file first time its working fine but when i try to ... >>> implement the filesystem ActiveX Object for WinCE. ...
    (microsoft.public.windowsce.app.development)