I want to install two files into a installation directory. The directory shall be selected by the user during installation and shall be created if it does not exist. A default path shall be proposed.
At the same time, an icon shall be placed on the desktop which includes information on the previously defined path (basically, I want to install the same files multiple times for different users, and both the directory name and the icon description shall show the user name)
Based on a previous discussion here, what I have so far is:
[Setup]
AppName=Test
AppVersion=1.0
DefaultDirName={userdocs}\Testprogramdir
AlwaysShowDirOnReadyPage = yes
DisableDirPage = no
OutputDir=Output
DefaultGroupName=Testgroup
PrivilegesRequired = lowest
OutputBaseFilename =Testsetupfile
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "program.exe"; DestDir: "{app}"
Source: "readme.txt"; Flags: onlyifdoesntexist; DestDir: "{app}"
[Icons]
Name: "{userdesktop}\program - username"; Filename: "{app}\program.exe"; Tasks: desktopicon
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
var
InstallDir: string;
begin
Result := True;
if CurPageID = wpSelectDir then begin
InstallDir := WizardForm.DirEdit.Text;
if not DirExists(InstallDir) then begin
if not CreateDir(InstallDir) then begin
MsgBox('Could not create installation directory.', mbError, MB_OK);
Result := False;
end;
end;
WizardForm.DirEdit.Text := InstallDir; // Update the directory edit field
end;
end;
How do I get the information on the directory name which was entered in the select wizard and is stored in the {app} variable to show up in the [Icons] section, instead of the hard coded "program - username" description?
Came up with a solution myself, thanks for the discussions: