Click here to Skip to main content
15,946,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For a registry key we can right click on particular key and selecting permissions option and adding new user by clicking on Add button.
Is it possible to do above things through code?Pls help..
Updated 18-Apr-12 18:41pm
Sergey Alexandrovich Kryukov 19-Apr-12 1:09am    
Not clear. What key? What user? A user of what? Do you want to add a user account to the OS? If so, this is not just a key...

Share this answer
The question is not clear — please see my comment to the question.

In case you want to create a new user account, I want to tell you just one thing: strictly speaking, you cannot do it by at least one simple reason: adding an account is not just adding some keys and other data to the Registry. This is explained here:[^].

Please pay attention that there are separate registry files for each user, NTUSER.DAT and USRCLASS.DAT, so you would need to create them, among other things. As before the files are created and before the newly created user is not logged on the usual .NET interface of Microsoft.Win32.Registry could not be applied to those files, you would need to create them on lower level. I am not sure if this is even documented.

Nevertheless, adding a new user account using .MET is possible, but is has nothing to do with (direct) Registry manipulations.

This is the Microsoft article explaining how to add a new user programmatically using Directory Services:;en-us;306273[^].

See also this discussion:[^].

Share this answer
saransath 19-Apr-12 2:25am    
Pls follow below steps.
Right click on any reistry key.Select "Permissions".In that there will be list of groups or user names.Is it possible to add user to that list using code?
Sergey Alexandrovich Kryukov 19-Apr-12 12:34pm    
You should better be way more clear in your questions.

How about exact key name? I only see the whole word "Permissions" in this key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Permissions

But the work "permissions" appears many times in the Registry. And what is the problem to add some data? You can use Microsoft.Win32.Registry.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900