Starting process is the usual thing which is always used, otherwise we would not have processes at all. The process is started when you start the application, but it is always done by some other, already executing process (the system startup process
bootstraps some of them, so you always have one to start with).
How? Please see:
https://msdn.microsoft.com/en-us/library/System.Diagnostics.Process(v=vs.110).aspx[
^],
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx[
^].
Stopping process? It depends what do you mean by stopping. There is only one legitimate way of terminating the process: when execution returns from the entry-point function of some application,
main
function. This is what really happens on after all those
Application.Exit
, closing of the main application window, and other numerous ways of quitting the applications, depending on all the technologies, languages and libraries. One special case is perhaps running on the top stack frame of the process's main thread which has the same effect and can also be considered acceptable, especially in some simple console-only applications. Note that it may not work in all cases. If you have any number of non-background threads other then main process thread, each of them will keep the process loaded, continuing the execution. All those threads should also exit their execution before the process can be terminated and unloaded.
Any other way of stopping the process is a bad thing. You really can terminate (kill) any process which is not ready to quit its execution. It can be considered only as a temporary measure if you have no other choice. For example, due to some bugs, you failed to find how to terminate all those non-background threads, or you have some external process which does not behave properly (bugs, extremely poor quality), not accessible for your patching. This is how this bad thing can be done:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill%28v=vs.110%29.aspx[
^].
This can work for both calling process or some other process, if your calling process has enough privileges to kill another one.
Don't do it! Always try to fix those bugs.
If you need to stop one process by another process,
the only legitimate way is this: you need to pass some notification to another process to request it to stop itself. Then, eventually, that process should quit execution in some of standard ways of doing so (ultimately, exit entry-point function). Naturally, that process should be designed for such kind of collaboration. In all cases, the notification mechanism is one of the IPC facilities, there are many of them, such as named pipe, messages, sockets.
And finally, shall we even discuss hiding of the process? I would not. I think this is the hack only attempted by some malicious software. I would stop this topic at this point. If you can mention any legitimate purpose of doing such things, I will gladly discuss it. But if you just want to hide some windows, please see my comment to the question above.
—SA