C# editing Registry does not work -


i trying registry editing. below code mcve of problem:

        registrykey key;         key = registry.localmachine.opensubkey("drivers", true);         key = key.createsubkey("names");         key.setvalue("name", "nick", registryvaluekind.string);         key.close(); 

that code works fine. following (changed drivers software) not:

        registrykey key;         key = registry.localmachine.opensubkey("software", true);         key = key.createsubkey("names");         key.setvalue("name", "nick", registryvaluekind.string);         key.close(); 

to me, difference between 2 blocks of code trivial. cause of issue, , how can around it? running code admin.

my end goal modify values in "software\microsoft\windows nt\currentversion\winlogon" folder.

i know possible powershell - should possible c# well.

you can write 64-bit registry 32-bit process, need explicitly request 64-bit registry follows (modified code in q).

var hklm = registrykey.openbasekey(microsoft.win32.registryhive.localmachine, registryview.registry64); registrykey key = hklm.opensubkey("software", true); key = key.createsubkey("names"); key.setvalue("name", "nick", registryvaluekind.string); key.close(); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -