我需要阻止或限制终止 VB.Net 应用程序。我对管理员杀死应用程序没有问题,但对用户没有问题。我一直无法为此提出解决方案。甚至有没有办法设置本地策略以防止非管理员终止?
注意:我以前看过这个问题,人们问“为什么”,假设这是出于恶意目的。这是一个 GUI 应用程序,必须根据策略保留在用户窗口的顶部。
更新:我知道这是可能的......我已经看到应用程序,当我尝试通过任务管理器终止它们时,我得到一个权限被拒绝。这就是我正在尝试做的...
If you handle formclosing event and say e.cancel if it is a normal user then it will be handled in your boundary. But you cannot enforce policy until and unless there is physical restriction applies in windows. I feel if you can remove the .NET keyword and put the question to IT specific guys it will help. In .NET you can do other than what I have explained in the initial statement.
当用户点击角落中的红色 X 时,以下代码将阻止您的表单关闭(因此应该停止您的应用程序关闭):
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason = CloseReason.UserClosing Then e.Cancel = True
End Sub
您无法阻止某人运行任务管理器并终止该进程,但您可以使用组策略阻止他们运行任务管理器