如何检查 windows 进程是由用户还是其他进程启动的?

How to check whether a windows process was launched by user or another process?

我的问题与 this 的问题非常相似,但我希望得到澄清。我特别询问 Windows。那里的评论中指出我们可以检查父进程。很好,但我想知道这在实践中有多稳健。

没有可靠的方法来验证进程是否是响应用户交互而启动的。

When a user launches a program, can you count on the parent process to be always the same (and what would that be)?

没有。用户可以与无数应用程序交互以启动进程(Windows File Explorer、Total Commander、Windows Command Prompt、ConEmu、Cygwin 等)。此外,当您检查时,父进程可能早已消失。

Conversely, if a program is launched by another program, can it somehow be made to appear that a user launched it?

用户启动的进程没有 属性 固有的。能不能建立一个不存在的属性这个问题比较哲学化。