end process in win2000 server

  • Thread starter Thread starter Janette
  • Start date Start date
J

Janette

Hi,

I am not sure if this is an appropriate group for this question, so please
feel free to direct me elsewhere.

I need to be able to programatically end a process in win2000 server. Ie
manually you would go to the task manager, go to the process tab and right
click on the process and choose end process. I need to be able to do this to
rogue processes using VBA 6.

Ie I want specifically to do the above manual step in a program, with the
same end effect. I have found reference to ExitProcess and TerminateProcess
but am unsure as to which is the equivalent of the manual method, and quite
how to use them.

Thanks for your time
Janette
 
Janette said:
Hi,

I am not sure if this is an appropriate group for this question, so please
feel free to direct me elsewhere.

I need to be able to programatically end a process in win2000 server. Ie
manually you would go to the task manager, go to the process tab and right
click on the process and choose end process. I need to be able to do this to
rogue processes using VBA 6.

Ie I want specifically to do the above manual step in a program, with the
same end effect. I have found reference to ExitProcess and TerminateProcess
but am unsure as to which is the equivalent of the manual method, and quite
how to use them.

ExitProcess can only be used to end the program it's called by. To end
another program you need to call TerminateProcess. Note that this should only
be done when there is no other way to end the program because it does not give
the program a chance to do proper clean-up.

In order to call TerminateProcess you will first have to get the Process
ID of the program (which can be done with the ToolHelp library) and then using
that PID, call OpenProcess specifying at least PROCESS_TERMINATE rights. Use
the handle returned by OpenProcess as the parameter for TerminateProcess.
 
Back
Top