Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can we write to registry key
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
with out admin priviliges in vb.net from the application

What I have tried:

Dim app = Path.GetFileName(Application.ExecutablePath)
        Dim Regkey As RegistryKey = Nothing
        Dim lobjCurrentUserSPClientRegistryKey As Microsoft.Win32.RegistryKey
        If Environment.Is64BitProcess Then
            Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION")  'For 32 bit machine
        Else
            Regkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION")
        End If

        Dim lobjCurrentUserRegistry As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine

        If Environment.Is64BitProcess Then
            lobjCurrentUserSPClientRegistryKey = lobjCurrentUserRegistry.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree)
            'Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", True)  'For 32 bit machine
        Else
            lobjCurrentUserSPClientRegistryKey = Regkey 'Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", True)
        End If


        If (lobjCurrentUserSPClientRegistryKey IsNot Nothing) Then
            Dim lobjRegistryPreToolDocSubKey As Microsoft.Win32.RegistryKey = lobjCurrentUserSPClientRegistryKey.OpenSubKey(app, RegistryKeyPermissionCheck.ReadWriteSubTree)

            If (lobjRegistryPreToolDocSubKey Is Nothing) Then
                '
                ' Create this "Previous Tool Documents" sub key.
                '
                lobjRegistryPreToolDocSubKey = lobjCurrentUserSPClientRegistryKey.CreateSubKey(app, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree)
            End If


            lobjRegistryPreToolDocSubKey.Dispose()
            lobjCurrentUserSPClientRegistryKey.Dispose()
            lobjCurrentUserRegistry.Dispose()

            SetRegistryValue("Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", app, "11001")
        End If
Posted
Updated 14-Apr-20 5:00am
Comments
Richard MacCutchan 14-Apr-20 9:18am    
No, you must have admin privileges to modify that key.
Vert12 14-Apr-20 9:48am    
thanks Richard

You cannot modify that key without admin rights for security reasons.
There is no way to get round that!
 
Share this answer
 
More generally, what you're writing to is under HKEY_LOCAL_MACHINE, the code must be running as an admin user in order to write to it.
 
Share this answer
 

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