简体   繁体   English

防止用户停止进程

[英]Prevent users from stopping a process

Long story short, I need to create an application that monitor the sound volume on a computer. 长话短说,我需要创建一个用于监视计算机音量的应用程序。 The computer's user must not be able to stop the application no matter what. 计算机的用户无论如何都不能停止该应用程序。

I'll need to make my app start on computer start up, so the user can't just restart it to enter his session without the application running. 我需要使我的应用程序在计算机启动时启动,因此用户不能在不运行应用程序的情况下重新启动它以进入他的会话。 As of now I don't know precisely how to do it but with some research this shouldn't be a problem. 到目前为止,我还不知道该怎么做,但是通过一些研究,这应该不是问题。

My biggest concern is if he just stops the process in the task manager. 我最大的担心是,他是否只是在任务管理器中停止了该过程。 I guess that I can't avoid that programmatically ? 我想我无法以编程方式避免这种情况? Is there a way to just modify the session's right so that it can't stop processes in the task manager? 有没有一种方法可以只修改会话的权限,以便它不能停止任务管理器中的进程? Or any other solution I didn't think about ? 还是我没有想到的其他解决方案?

Or there is no way I can do that and I'll just have to trust my user not to ever stop the program in the task manager ? 还是没有办法做到这一点,而我只需要信任我的用户就不要停止任务管理器中的程序了?

Thanks in advance for your help. 在此先感谢您的帮助。 :) :)

PS : This will run on a computer in a student club that runs the music for the club and that anyone can access. PS:它将在学生俱乐部的计算机上运行,​​该计算机运行俱乐部的音乐,任何人都可以访问。 There are chambers where people sleep the floors above so we don't want people to put the volume too loud. 有一些房间供人们在上面的地板上睡觉,所以我们不希望人们将音量过大。 That's it. 而已。 No malware or anything. 没有恶意软件或任何东西。

In general, the only programs that act like that are malicious (eg rootkits ). 通常,只有这样的程序才是恶意的(例如rootkits )。 If you think about it, you really wouldn't want programs to be able to act like that. 如果您考虑一下,您确实不希望程序能够那样做。

As others have indicated, the closest you'll get here is a Windows Service, which automatically starts with Windows. 正如其他人指出的那样,最接近您的是Windows服务,它将自动从Windows启动。 Average users won't know to stop it, but it's still possible to stop it manually for power users. 一般用户不知道要停止它,但是对于高级用户仍然可以手动停止它。

One work-around you could try is to periodically have it call a web service to verify that it's running. 您可以尝试的一种解决方法是定期让它调用Web服务以验证其是否正在运行。 That way you could tell who might have uninstalled or stopped the service. 这样,您可以告诉谁可能卸载或停止了该服务。 (The problem, of course, is that they might just not have their computer on or something; you could have separate calls for "Start" and "Still On"). (当然,问题在于他们可能只是没有打开计算机或什么东西;您可能需要分别调用“开始”和“保持打开”)。

Alternatively, if this installed only on computers that are exclusively under your direct control, as others have indicated, you could configure things so that you need administrative access to stop the process. 另外,如果仅在直接控制的计算机上安装了此程序,如其他人所指出的,则可以进行配置,以便需要管理访问权限才能停止该过程。 This option was addressed in the comments. 评论中提到了此选项。

I'm not accusing you of malware - just wanted to illustrate how bad it would be if you could easily make a program that the user can "never stop". 我并不是在指责您恶意软件-只是想说明一下,如果您可以轻松地编写一个用户可以“永不停止”的程序,那将是多么糟糕。

So no you can't make a program that a computer-savvy person could never stop. 因此, 不,您无法制作出一个精通计算机的人永远无法停止的程序。

But from what I gathered.... 但是从我的聚集中...

Sounds like you want to make it a service. 听起来好像您想使其成为一项服务。 https://msdn.microsoft.com/en-us/library/d56de412(v=vs.110).aspx . https://msdn.microsoft.com/zh-CN/library/d56de412(v=vs.110).aspx

Another (easier I think) option is just to make a console app that starts up from the Task Scheduler http://www.c-sharpcorner.com/uploadfile/manas1/console-application-using-windows-scheduler/ . 另一个(我认为更容易)的选择是制作一个从Task Scheduler启动的控制台应用程序, 网址为http://www.c-sharpcorner.com/uploadfile/manas1/console-application-using-windows-scheduler/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM