I need to disable and enable the taskmanager from my application.
I am doing this for my Kiosk application. I know i can do this
by changing the Key in registry using below code. But the problem
is my kiosk application will run in limited user account which does
not allow the application to change key in registry level.
Code working perfectly in Administrator account :
RegistryKey regkey;
string keyValueInt = "1";
string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
regkey = Registry.CurrentUser.CreateSubKey(subKey);
regkey.SetValue("DisableTaskMgr", keyValueInt);
regkey.Close();
How can i achieve this in Limited user account ?
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.
http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx