0

I need to add a new registry key to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRunTime\AllowedCOMCLSIDs.

I tried running a following bat script:

@echo off 
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\AllowedCOMCLSIDs\NewKey" /f /ve
PAUSE

What I got in return was an access denied message, tried doing the same by launching a cmd.exe as an administrator but got the same information. I only have one account on this computer and it has the admin rights.

I also tried running this script to see if it can add that key to a different directory under HKEY_LOCAL_MACHINE and so I ran this script:

@echo off 
reg add HKEY_CURRENT_USER\Software\NewKey /f /ve
PAUSE

And that script was completed successfully.

Any idea how can I make the first one run properly as well? I've searched through multiple questions, threads and video tutorials showing modifications of users' groups properties but it doesn't really apply in this case, nothing changes since I already have all the rights assigned.

I'd be grateful for your help.

Edit: Ok, thanks everyone for your comments, I didn't have a clue that you can change the permissions for keys as well. Had to change the owner from SYSTEM to my account and then grant full permissions for those accounts and now the .bat script completes successfully.

Additional question - is it possible to change the owner of a given key file and grant the required permissions all in a single .bat file?

4
  • 1
    Having admin rights is not necessarily enough to access certain sensitive areas of the system. Right click the parent key and check the permissions and see if this path is restricted to system or trustedinstaller, etc. make sure if actually provides administrators, users or everyone with write access. Anti-virus software may also produce results like this. Commented Dec 1, 2022 at 17:47
  • @Appleoddity You might as well make that a full answer instead of a comment. That is exactly what is going on here.
    – Tonny
    Commented Dec 1, 2022 at 19:20
  • Provide a screenshot of the ACL for `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\AllowedCOMCLSIDs` as an edit to your question.
    – Ramhound
    Commented Dec 1, 2022 at 22:45
  • Didn't know that the keys also have the owners and you can grant permissions to change them - TIL. Thanks for help! Any idea if it's possible to change those owners and permissions using a bat file as well? Would like to automate it. Commented Dec 2, 2022 at 18:39

1 Answer 1

0

The key HKEY_CURRENT_USER contains user data that is mostly entirely accessible and modifiable by the current user.

The key HKEY_LOCAL_MACHINE contains system-wide data, some of it very sensible, so modifying it usually requires administrator permissions. However, some data is crucial for Windows to work correctly, so the permissions for those key are exclusively kept by the TrustedInstaller account. An administrator account does not have the permissions to modify data owned by the TrustedInstaller account.

This is exactly the situation with the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\AllowedCOMCLSIDs, whose permissions are as follows:

enter image description here

The key is owned by TrustedInstaller, which is the only account that has full control of the key.

In short - you cannot modify this key. Windows will not allow it.

You need to find a way of doing what you're trying to do using some built-in Windows application that has the right permissions. I suggest detailing your underlying problem in a new question, asking for a solution that doesn't require modifying registry keys that are reserved by Windows.

3
  • The author could change the permissions of the key, in theory, but it's not advised and there is a good reason that particular key is protected.
    – Ramhound
    Commented Dec 1, 2022 at 22:46
  • @Ramhound I just did that, changed the permissions which allowed the script to do its job. Thanks for help! Commented Dec 2, 2022 at 18:37
  • That required taking ownership of a vital Windows registry key, which might later cause unpredictable side-effects.
    – harrymc
    Commented Dec 2, 2022 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .