Maciek Kowalski
Maciek Kowalski

Reputation: 23

Taking ownership over registry key in Inno Setup

I am trying to take ownership of this key via installer (to automate work):

Computer\HKEY_CLASSES_ROOT\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}

or

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}

By default, the owner is TrustedInstaller. I cannot do this via HKCU because the change is supposed to work for all users (changing RunAs to _RunAs).

I use the command (or Root: HKCR ofc):

Root: HKLM; Subkey: "Software\Classes\AppID{{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}"; ValueType: string; Permissions: admins-full
Root: HKLM; Subkey: "Software\Classes\AppID\{{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}"; ValueName: "RunAS"; Flags: deletevalue
Root: HKLM; Subkey: "Software\Classes\AppID\{{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}"; ValueType: string; ValueName: "_RunAS"; ValueData: "Interactive User"
Root: HKLM; Subkey: "Software\Classes\AppID\{{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}"; ValueType: dword ; ValueName: "AppIDFlags"; ValueData: "1"

Unfortunately nothing happens, on the other computer where I manually set the owner to "users" after running this command only the permissions are added but the owner unfortunately remains the same. Of course I run everything with administrator rights and I have read the whole Registry section.

Upvotes: 1

Views: 296

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202271

Inno Setup cannot change owner of the key.

But you can ask Inno Setup to re-create the key using the deletekey flag. What should change the owner to the account that runs the installer as a side effect. But it will obviously delete all subkeys and values too.

[Registry]
Root: HKLM; Subkey: "Software\Classes\AppID{{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}"; \
  Flags: deletekey

If you need to change the owner, while preserving the contents, you will have to run an external tool for that. Like a PowerShell code:
How do I take ownership of a registry key via PowerShell?

Upvotes: 1

Related Questions