MHD
MHD

Reputation: 47

add item to key in registry with vb or c# AND get Administrative Access

I want add item to a key in registry and find "CreateSubKey" command but point is this command create sub key not item to a key. for example path of "Computer\HKEY_USERS.DEFAULT\Control Panel\International" has about 40 item and 3 sub key. I want add item to "\International" not sub key.

another problem is that when I want add subkey to another users in "Computer\HKEY_USERS" path ,I got error "cant access other user registry" .how could I handle that with code without login as admin in windows?

LOOK AT PICTURE: enter image description here best regards.

Upvotes: 0

Views: 259

Answers (1)

Anders
Anders

Reputation: 101746

Create the key you are interested in and then set the values:

RegistryKey rk = Registry.Users.CreateSubKey("DEFAULT\\Control Panel\\International");
rk.SetValue("a number", 42);
rk.SetValue("my string", "fiftythree");

You have to be elevated administrator to modify keys in roots other than CurrentUser. Normal users are not allowed to modify machine settings nor the settings of other users.

Upvotes: 0

Related Questions