How to get permission to write in the Windows registry via VB to HKEY_LOCAL_MACHINE key

Asked

Viewed 2,105 times

0

Guys I’m trying to record a record inside the HKEY_LOCAL_MACHINE\SYSTEM and visual studio / visual basic won’t let me have access. It says I’m not allowed to record my record.

My command:

My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM", "1", &H1I, Microsoft.Win32.RegistryValueKind.DWord)

The mistake:

System.UnauthorizedAccessException

Thank you to all who can help ; I will share my project here at the end in thanks to the whole community.

  • Wouldn’t that be a system permission? Visual Studio can’t override the permissions of the user running the service.

  • So I applied the regedit to everyone and it still doesn’t record . Crazy ; I never saw that .

  • In the Current_user folder goes normal .

  • Tried everything here @Tiagocésaroliveira .

  • Obtain@tiagocésaroliveira was the most permission as I put it straight through the basic look ? Because I can’t tell my user to just go there in a know in which folder and Talz and apply the permission it would have to be given direct by VB .

  • @Mauriciopeffoni this is a windows user permission, it cannot be programmatically set...

  • Kick from a non-specialist in the field: and if you run your executable (your compiled program) as the machine administrator, it records?

Show 2 more comments

1 answer

4


The HKEY_LOCAL_MACHINE key only allows recording if the user logged in to Windows is administrator, and in the case of UAC if the program that is trying to modify the value has been run with high permissions.

In general no change should be made within HKEY_LOCAL_MACHINE, any program configuration for example should be saved in HKEY_CURRENT_USER

  • I understand your position . Even in the Current user he is asking for permission and am the user’s Adm .

  • I did a test and switching to HKEY_CURRENT_USER he recorded without problems using his code. Only I do not understand why you want to write in the key "System", in general one should not use any key that is not one created by you inside the key "Software".

  • Thanks Leandro for the consideration; Is there any method of acquiring rights on the access key ? A command or something ? @Leandro Godoy Rosa

Browser other questions tagged

You are not signed in. Login or sign up in order to post.