8

How to write install path to registry after install is complete with Inno sSetup?

Thanks in advance!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user441222
  • 2,001
  • 7
  • 27
  • 41
  • 3
    It depends on what you mean by *after install is complete*. In your case I don't think you need to do this *after install is complete* thus your answer is sufficient. But to be more precise, the `[Registry]` section [`is processed`](http://jrsoftware.org/ishelp/topic_installorder.htm) at the time the installation is not fully completed yet. If you'd do something really *after install is complete*, you should do it in the [`CurStepChanged`](http://jrsoftware.org/ishelp/topic_scriptevents.htm#CurStepChanged) event handler when the `CurStep` parameter equals to `ssPostInstall`. – TLama Nov 24 '12 at 09:50
  • 2
    Or if you need to do something related to just one installation entry (e.g. file), you can use the [`AfterInstall`](http://jrsoftware.org/ishelp/topic_scriptinstall.htm#AfterInstall) parameter. – TLama Nov 24 '12 at 09:51

2 Answers2

12

Like TLama said, you can achieve it via ssPostInstall if you want the key to be added after the installation process is complete.

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssPostInstall then begin
     RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\HHSTECH',
    'InstallPath', ExpandConstant('{app}'));
  end;
end;

Or you can use AfterInstall that will be called after the last files is installed (copied).

[Files]
Source: ".\THEVERYLASTFILE.XXX"; DestDir: "{app}"; AfterInstall: MyAfterInstall

[Code]
procedure MyAfterInstall();
begin
     RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\HHSTECH',
    'InstallPath', ExpandConstant('{app}'));
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
RobeN
  • 5,346
  • 1
  • 33
  • 50
7
[Registry]
Root: HKLM; Subkey: Software\HHSTECH; ValueType: string; ValueName: InstallPath; ValueData: {app}
user441222
  • 2,001
  • 7
  • 27
  • 41