禁止使用C#在OS淬火机任务管理器 [英] Disabling Task manager using c# in OS Hardened machine

查看:102
本文介绍了禁止使用C#在OS淬火机任务管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码以禁用亭应用程序,它完美的作品在任务管理器

I am using the below code to disable the task manager for a kiosk application which works perfectly

    public void DisableTaskManager()
    {
        RegistryKey regkey;
        string keyValueInt = "1";
        string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";

        try
        {
            regkey = Registry.CurrentUser.CreateSubKey(subKey);
            regkey.SetValue("DisableTaskMgr", keyValueInt);
            regkey.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show("DisableTaskManager" + ex.ToString());
        }
    }



但是,当我在OS淬火机运行此我得到下面的错误,

But when i run this in OS hardened machine i get the following error,

DisableTaskManagerSystem.UnauthorizedAccessException: 
Access to the registry key 'HKey_Current_User\Software\Mictrosoft\Windows\CurrentVersion\Policies\System' is denied.
at Microsoft.win32.RegistryKey.win32Error(int32 errorcode, String str)



如何能我克服这个?我需要为Kiosk应用程序做到这一点。

How can i overcome this ? I need to do this for a Kiosk application.

推荐答案

中的代码需要提升的权限来访问注册表。但是存在的仅仅是需要这些额外许可的代码片段。为了处理这些场景模拟使用,即,如果你是管理员,您将执行这个应用程序,因为只有普通用户,但该特定的代码会被执行。

the code requires an elevated privilege to access registry. However there is just a fragment of code that requires these extra permission. To handle such scenarios impersonation is used i.e. you will execute this application as normal user only but that particular piece of code will be executed as if you were an Administrator.

<一个HREF =http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx相对=nofollow> http://msdn.microsoft.com/en-us/library /system.security.principal.windowsimpersonationcontext.aspx

这篇关于禁止使用C#在OS淬火机任务管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆