Inno Setup Prompt user for a folder and store the

2019-06-13 04:35发布

问题:

I have following need:

[Run] 
;run robocopy.exe source dest/OLD/[source_contents] /options

Where:
source must be specified by user on the destination machine (this can change according the physical platform)
destination will be identical to the just user-defined source folder while the subpath OLD/[source_contents] will be automatically created by the robocopy input.

I was thinking to use a "scripted-constant", but the problem is that I need to store some way the "source" prompted parameter some where (I cannot require two prompts for the same place).

Thanks.

回答1:

The scripted constant is a way to go. Just just need to make sure you prompt the user just once and reuse the results for both the source an the destination path.

You can for example use CreateInputDirPage and implement the scripted constant to refer to a path that a user specified on the page:

[Run]
Filename: "robocopy.exe"; Parameters: "{code:CopyDir} {code:CopyDir}\OLD"
[Code]
var
  CopyDirPage: TInputDirWizardPage;

procedure InitializeWizard();
begin
  CopyDirPage :=
    CreateInputDirPage(wpSelectDir, 'Select source directory', '',  '', False, '');
  CopyDirPage.Add('Source directory:');
end;

function CopyDir(Params: string): string;
begin
  Result := CopyDirPage.Values[0];
end;