Vista + VB.NET - Access Denied while writing to HKEY_LOCAL_MACHINE

前端 未结 3 1157
挽巷
挽巷 2021-01-23 21:39

I want my program to be able to edit a values within a registry key that resides in \'HKEY_LOCAL_MACHINE\'

    My.Computer.Registry.SetValue(\"HKEY_LOCAL_MACHINE         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-01-23 21:51

    Since changes to the Local Machine hive can have affect across the system you will find that changes to it are restricted to non-administrative users. If you try to run your same code on an XP machine a non-admin account you will get the same error. On Vista since the process is non-admin by default you are getting this error. Information on this is in the "Made for Windows 2000", "Made for Windows XP", and "Made for Windows Vista" certification guidelines.

    Given that I've got little information on what your program is doing more information may be needed to give you specific guidance, so I will speak in the general case. You want your application to leave the local machine hive alone unless you need it. When your program is run in non-admin mode it you can either disable the functionality that requires access to these admin keys or you can request that the admin privs.

提交回复
热议问题