title: Specify the registry uninstall key location/hive via [Code]
body: <p>Inno Setup by default looks at the <code>PrivilegesRequired</code> setup variable, if this is set to <code>admin</code> or <code>poweruser</code>, the installer installs the uninstall registry key to <code>HKLM</code>. If this is set to <code>lowest</code>, then it will install the registry entries to <code>HKCU</code>. </p>
  
  <p>I have a requirement to provide the user an option to install for "just me" or "everybody", and have done so by replacing the dir selection page with a radio selection of these two options. what I need to do now is also modify the registry install location based on this setting. If I install the app into the local user app data, it won't make sense to register the uninstall data at the <code>HKLM</code> level, because then other users will see it in the programs list and still be unable to uninstall or use it.</p>
  
  <p><strong>Edit:</strong> After looking through the documentation and the source of <code>Install.pas</code>, I found the <code>CreateUninstallRegKey</code> setup directive, which will disable Inno from installing registry keys at all, after which I can add my own registry entries, but is this really the only way?</p>
  
  <p><strong>Edit #2 (marked as duplicate):</strong> I've already taken a look at this <a href="https://stackoverflow.com/questions/21556853/make-inno-setup-installer-request-privileges-elevation-only-when-needed">Conditional Elevation</a> question (and actually implemented it), and it's not the same as mine. The current elevation state does <strong><em>not</em></strong> alter where Inno Setup actually saves the uninstall registry info (in HKCU or HKLM). If you look at the <a href="https://github.com/jrsoftware/issrc/blob/0909095f63a6a7fc48d252605fd2437416be0fdb/Projects/Install.pas#L507" rel="nofollow noreferrer">Inno source code (Install.pas #507)</a> you'll see that the <code>PrivilegesRequired</code> directive is the primary factor in where the registry is stored. If this is set to <code>lowest</code>, it doesnt matter if the installer is elevated or not - it will install the registry keys to HKCU, when the desired behavior is to select one or the other based on the users install preference, NOT the current elevation state. So all this being said, I'm looking for a solution to alter the registry root based on a code variable, regardless of current PrivilegesRequired or Elevation setting.</p>