1

Update:

I have succeeded in making my installer work properly. ( added the release notes, license agreement section, choosing the location where the program is to be installed, having it generate me an destop shortcup etc.) what i want to add it, that during the instalation, I want the user to choose the path to where he has installed his JDK. I want to take this path, create a system environment variable with the name JAVA_HOME and have it's value be this chosen path. How do i do this? It is kind off diifficult to show my code because i am on my phone. But if i have to i will make an effort to do so.

Roger Federer
  • 329
  • 2
  • 6
  • 12

1 Answers1

1

Based on

[Setup]
ChangesEnvironment=yes

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
    ValueType: string; ValueName: "JAVA_HOME"; ValueData:"{code:GetJavaHome}"; \
    Flags: preservestringtype

[Code]

var
  JavaHomePage: TInputDirWizardPage;

procedure InitializeWizard();
begin
  JavaHomePage :=
    CreateInputDirPage(
      wpSelectDir, 'Java Path', 'Where do you have Java installed to?', '', False, '');
  JavaHomePage.Add('');
end;

function GetJavaHome(Param: string): string;
begin
  Result := JavaHomePage.Values[0];
end;

If you want to offer some meaningful default, see also an answer by @Matthieu to Inno Setup - Setting Java Environment Variable.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992