如何禁止普通用户终止进程?
我无法将其实现为 Windows 服务,因为我的进程必须与桌面交互,而 Windows 7 中禁止这样做。
实现此目的最简单的方法是什么?在另一个(特权)用户下启动?如何做到这一点?
我的用户不是黑客,只是操作员,因此一些“愚蠢”的方法(例如隐藏任务管理器)也会有所帮助。
编辑:根据提供的答案进行一些澄清
我的进程没有任何 GUI,所以我试图避免从任务管理器终止该进程
我的进程是必须监视用户桌面的监督系统的客户端,因此它必须与桌面交互
编辑2:
我可以使用Windows服务在系统帐户下的用户会话中启动单独的进程(因为我的服务在系统帐户下运行)?用户可以杀死这个子进程吗?
I cannot implement it as a windows service because my process has to interact with desktop and it's prohibited in Windows 7.
What is the simplest way to accomplish this? Starting under another (privileged) user? How to do this?
My users are not hackers, just an operators, so some "dumb" methods like hiding from task manager would help too.
EDIT: some clarification according to provided answers
my process doesn't have any GUI, so I'm trying to avoid killing the process from task manager
my process is a client of a supervising system that has to monitor user's desktop, so it has to interact with desktop
EDIT 2:
can I use a windows service that will start separate process in user session under system account (since my service is running under system account)? can user kill this child process?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
经过长时间的挖掘,我在这里找到了可接受的答案: 防止用户进程被 Process Explorer 中的“结束进程”杀死
如果您以普通用户身份登录,则可以正常工作,您无法从 Process Explorer 中杀死进程。管理员仍然可以杀死它,因为有足够的权限。这正是我所需要的
after long digging I found acceptable answer here: Prevent user process from being killed with "End Process" from Process Explorer
works fine if you're logged in as a regular user, you cannot kill the process from Process Explorer. Admin still can kill it because has sufficient privileges. it's exactly what I needed
您可以 使用组策略禁用任务管理器,并隐藏应用程序窗口中的关闭按钮和 [Alt+F4] 上的反应。
You could disable the task manager using a Group Policy and hide the close button from you application's window and the reaction on [Alt+F4].
关闭(根)窗口并不意味着停止进程 - 当消息泵循环存在时,您可以使用新窗口重新启动它(显然,如果您使用的是框架,则可能有一个包装器围绕它)。
但是,如果用户拥有一个 Windows 对象(如进程),他们总是可以删除(终止)它。但是,以不同用户身份运行时,用户的凭据需要以当前用户运行的启动器可以访问的方式存储。
为了提供更具体的帮助,我认为我们需要了解原因:
是一个要求。
Closing the (root) window doesn't mean stopping the process – when the message pump loop exists you could just re-start it with a new window (clearly if you are using a framework there is probably a wrapper around this).
But if a user owns a windows object (like a process) they can always delete (terminate) it. But running as a different user that user's credentials will need to be stored in a way that's accessible to the launcher running as the current user.
To help more specifically I think we need to understand why:
is a requirement.
从这个 MSDN 博客:
操作方法如下:
通过调用 CreateProcessAsUser 中的“使用此令牌”来获取用户令牌
。
您只需从服务中调用
WTSQueryUserToken
并启动该进程 - 它也适用于 Windows 7!From this MSDN blog:
This is how you do it:
Get the user token by calling
Use this token in CreateProcessAsUser.
You just need to call
WTSQueryUserToken
from your service, and launch the process - it works on Windows 7 too!