Registry under HKEY LOCAL_MACHINE is not working

Nethi, Yaswanth 0 Reputation points
2025-01-20T11:17:02.5266667+00:00

I needed to give administration previligiles for c:\tensor\bin\startup.exe to all users in the windows machine. For that, I needed to create registry key following path.

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

Inside the Layers key, I created string registry like c:\tensor\bin\startup.exe through installer where value is "~RUNASADMIN". It's worked as expected.

I needed to add the same registry value in to the LOCAL_MACHINE instead of CURRENT_USER. I removed previously created registry under CURRENT_USER and created new registry under

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

But it's not worked as expected. What could be the issue? And installer is running as administrator only

Windows 10 Compatibility
Windows 10 Compatibility
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Compatibility: The extent to which hardware or software adheres to an accepted standard.
484 questions
Windows 10 Security
Windows 10 Security
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
2,985 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Zafer KAYA 20 Reputation points MVP
    2025-01-20T11:32:24.6766667+00:00

    Permissions Issue on HKEY_LOCAL_MACHINE:

    • The key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers is a system-wide registry setting and requires administrative privileges to write to. While your installer is running as an administrator, it may not have the necessary permissions to write to this registry key for all users.
    • Solution: Ensure that the installer is running with elevated privileges (i.e., Run as Administrator). Even though it’s being executed with admin rights, certain keys may require additional permission handling, especially on 64-bit systems where the registry paths for 32-bit and 64-bit applications are separated. If you are working on a 64-bit system, ensure the installer is writing to the correct registry view:
    • For 64-bit systems, use HKEY_LOCAL_MACHINE\SOFTWARE for 64-bit applications.
      • For 32-bit applications, use HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node for the appropriate 32-bit registry hive.
      • User-Specific Registry Entries in HKCU vs. HKLM:
      • HKEY_CURRENT_USER (HKCU) is user-specific, while HKEY_LOCAL_MACHINE (HKLM) is system-wide. When you set a value under HKCU, it applies only to the current logged-in user. When you attempt to apply the same setting under HKLM, it should apply system-wide but requires elevated privileges.
        • Solution: If your goal is to apply the setting to all users, make sure you are modifying the registry under HKEY_LOCAL_MACHINE for all users, but also ensure that you have the necessary administrative rights.
        • Correct Registry Path and Formatting:
          • Ensure the registry path is correct and formatted properly:
          • The registry value you are adding should be a string value (REG_SZ), and the value data should be the path to the executable with the ~RUNASADMIN flag.
            • Double-check the key path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers and verify that there are no typographical errors in the path.
            • System Reboot:
              • Sometimes, changes made to the registry, especially for HKEY_LOCAL_MACHINE, may require a system reboot to take effect.
          • 32-bit vs. 64-bit Registry View:
          • On 64-bit systems, there are separate registry hives for 32-bit and 64-bit applications. If the application is 32-bit, it might not be reading from the expected HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers (which is typically for 64-bit apps).
            • Solution: Use the HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers registry path for 32-bit applications on a 64-bit machine.
    0 comments No comments

  2. Hania Lian 20,916 Reputation points Microsoft Vendor
    2025-01-22T09:22:21.7933333+00:00

    Hello,

    Here are a few things you might want to check:

    User Account Control (UAC) settings can sometimes interfere with running applications as administrators. If UAC is set too high, it may prompt for confirmation even when running as an administrator. Make sure UAC settings are configured properly.

    There might be some Group Policy settings that override your changes or restrict certain modifications to the registry. Check if there are any policies set up that might affect this.

    Changes registry require a reboot of the machine to take effect. Try restarting the computer after making the changes.

    If the issue persists, try creating a new user profile and see if the application runs with elevated privileges there.

    Best Regards,

    Hania Lian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.