Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requested registry access is not allowed

I'm writing a tweak utility that modifies some keys under HKEY_CLASSES_ROOT.

All works fine under Windows XP and so on. But I'm getting error Requested registry access is not allowed under Windows 7. Vista and 2008 I guess too.

How should I modify my code to add UAC support?

like image 510
abatishchev Avatar asked Feb 18 '09 18:02

abatishchev


People also ask

What does Requested registry access is not allowed mean?

You are attempting to install the SQL Server 2008 R2 ACT7 instance when you receive the following error message: "Requested registry access is not allowed " This issue can occur if an existing key the Windows® Registry does not have adequate permissions, which can cause the SQL Server 2008 R2 installation to fail.


2 Answers

app.manifest should be like this:

<?xml version="1.0" encoding="utf-8"?> <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">       <security>          <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">             <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />          </requestedPrivileges>       </security>    </trustInfo> </asmv1:assembly> 
like image 149
abatishchev Avatar answered Oct 09 '22 13:10

abatishchev


You can't write to the HKCR (or HKLM) hives in Vista and newer versions of Windows unless you have administrative privileges. Therefore, you'll either need to be logged in as an Administrator before you run your utility, give it a manifest that says it requires Administrator level (which will prompt the user for Admin login info), or quit changing things in places that non-Administrators shouldn't be playing. :-)

like image 30
Ken White Avatar answered Oct 09 '22 11:10

Ken White