禁用Taskmanager时的管理员权限
本文关键字:管理员 权限 Taskmanager 禁用 | 更新日期: 2023-09-27 18:14:22
没有管理员权限如何执行此代码?
RegistryKey key = Registry.CurrentUser.CreateSubKey("Software''Microsoft''Windows''CurrentVersion''Policies''System");
private void button1_Click(object sender, EventArgs e)
{
key.SetValue("DisableTaskMgr", 1);
}
private void button2_Click(object sender, EventArgs e)
{
Registry.CurrentUser.DeleteSubKey("Software''Microsoft''Windows''CurrentVersion''Policies''System");
// Or you can change the key value to 0
}
您可以创建一个清单文件并添加以下代码,这将把您的程序提升到更高的特权模式。因此,您可以执行该程序。
1. Add a new file to you project called App.manifest; by adding a new File from
Project.
2. Add following data to that file, rest it will do the magic.
只需将您的应用程序名称替换为YourAssemblyName。最重要的部分是section。其余部分是自动生成的
<?xml version="1.0" encoding="utf-8" ?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="YourAssemblyName" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator"
uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</asmv1:assembly>