[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Help!!! How to kill a Process

Ming Zhang

10/16/2002 6:40:00 PM

Hi experts:
I wrote a C# program to kill a process by calling Process.Kill(). It works
fine when I debug it(press F5). It even works when I launch it from
DevStudio without debug(press Ctrl+F5). But when I run the exe directly, it
throws an exception say "Access Denied".
Any suggestion.

Thanks


4 Answers

Brian Gideon

10/17/2002 4:47:00 PM

0

My guess is that you're trying to kill a process that wasn't started under
your login. When starting the program from VS.NET it may be running under a
different login with elevated privileges which might explain why it works in
that situation and not the other.

Brian

"Ming Zhang" <mzhang@mpsbc.com> wrote in message
news:u#33wrTdCHA.2408@tkmsftngp11...
> Hi experts:
> I wrote a C# program to kill a process by calling Process.Kill(). It works
> fine when I debug it(press F5). It even works when I launch it from
> DevStudio without debug(press Ctrl+F5). But when I run the exe directly,
it
> throws an exception say "Access Denied".
> Any suggestion.
>
> Thanks
>
>


Ming Zhang

10/17/2002 7:05:00 PM

0

Thanks for your reply.
This is want I guessed too. But how to change privilege in code? There are
must be a way since DevStudio can do it.
Appreciate for your help.

Thanks

"Brian Gideon" <briangideon@yahoo.com> wrote in message
news:uZ1sTRfdCHA.1732@tkmsftngp08...
> My guess is that you're trying to kill a process that wasn't started under
> your login. When starting the program from VS.NET it may be running under
a
> different login with elevated privileges which might explain why it works
in
> that situation and not the other.
>
> Brian
>
> "Ming Zhang" <mzhang@mpsbc.com> wrote in message
> news:u#33wrTdCHA.2408@tkmsftngp11...
> > Hi experts:
> > I wrote a C# program to kill a process by calling Process.Kill(). It
works
> > fine when I debug it(press F5). It even works when I launch it from
> > DevStudio without debug(press Ctrl+F5). But when I run the exe directly,
> it
> > throws an exception say "Access Denied".
> > Any suggestion.
> >
> > Thanks
> >
> >
>
>


Brian Gideon

10/17/2002 10:40:00 PM

0

I have no idea. In fact, I'm not even sure what I said was entirely
accurate. It was only a guess.

Brian

"Ming Zhang" <mzhang@mpsbc.com> wrote in message
news:u9YzhegdCHA.1300@tkmsftngp08...
> Thanks for your reply.
> This is want I guessed too. But how to change privilege in code? There are
> must be a way since DevStudio can do it.
> Appreciate for your help.
>
> Thanks
>


Rick Strahl

10/17/2002 11:13:00 PM

0


I think you may have to use TerminateProcess in the Win32API to shut down a
process in another logon session. To use it you'll need a handle to the
process - not sure whether you can get it out of the Process class.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west...
http://www.west...wwthreads/
-----------------------------------
Making waves on the Web with Visual FoxPro
"Ming Zhang" <mzhang@mpsbc.com> wrote in message
news:u#33wrTdCHA.2408@tkmsftngp11...
> Hi experts:
> I wrote a C# program to kill a process by calling Process.Kill(). It works
> fine when I debug it(press F5). It even works when I launch it from
> DevStudio without debug(press Ctrl+F5). But when I run the exe directly,
it
> throws an exception say "Access Denied".
> Any suggestion.
>
> Thanks
>
>