What is the best way to kill a critical process?
It's critical for a reason so you probably shouldn't be killing it at all. The best way is to shut down the box lest you leave it in a dangerous state.
If you choose to ignore my warning, here is some sample C++ code to do it.
Invoking the kill function in signal.h is one way to killing a process in C. No idea about the alternations in C++.
Edit : Have a look on this code.
This knowledge base article describes how to do it. You first call SeDebugPrivilege()
to obtain the privileges to terminate processes, then you call OpenProcess()
with the PROCESS_TERMINATE
flag to get a handle to the process you wish to terminate, and then finally you call TerminateProcess()
to terminate the process.
Yup, do what Adam suggested. Then watch as your machine bluescreens since you just terminated a critical process :) (btw, to be clear: Adam's suggestion is 100% accurate, it's not my intent to criticize it at all).
Why do you want to do this? There's a reason they're called critical processes.