.NET 如何在各版 Windows 特别是 Windows 7 上禁用任务管理器

Posted by Admin L in .NET Programming on 17-06-2011. Tags:

作者:牧山道人
原文地址:https://www.seeksunslowly.com/disable-task-manager-dot-net-sc
转载请注明出处,谢谢。
_____________________________________

有时,我们需要暂进禁用任务管理器,以免用户结束某个程序。

在网上找了一些资料,有说以二进制 stream 形式先打开 C:\windows\system32\taskmgr.exe 及 C:\windows\syswow64\taskmgr.exe 程序,使后续无法手工正常打开任务管理器;也有说增加注册表条目:在 HKEY_CURRENT_USER\Software\Microsoft\Windows\Current Version\Policies\System 下增加一 32 位 DWORD 型值,命名为 DisableTaskMgr 并将值设为 1。

以上方法在 Vista 以下系统上工作正常,但到了 Vista/Win7,由于 UAC 及权限原因,根本就行不通。
下面是我经过研究总结出的简单可行方法(VB 2008):

1、新建 Windows Forms Application。
2、放置一个 Timer 控件(位于 Components 分类下)到窗体上。
3、在窗体设计器底部选中 Timer1,并按下 ,将 Enable 属性设为 True,Interval 设为 600。
4、双击 Timer1,贴上以下代码:
[cc lang=”vbnet”]
For Each p As Process In Process.GetProcesses()
If p.ProcessName.ToLower = “taskmgr” Then p.Kill() : Exit For
Next
[/cc]
5、运行代码,尝试以各种方式打开任务管理器(开始菜单、任务栏右击、Ctrl + Alt + Del),均无法实施:要么立即被关闭,要么提示 “Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the item.”(在 Windows 7 上是这个提示)。至此,实现目标。

源码下载:
https://www.seeksunslowly.com/downloadable-source-codes/disable-task-manager-dot-net.zip

【赞赏 / Reward】

微信         支付宝         PayPal

Post a comment