Inno Setup Prompt user for a folder and store the value

早过忘川 提交于 2019-12-10 11:59:06

问题


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. You 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;


来源:https://stackoverflow.com/questions/33735226/inno-setup-prompt-user-for-a-folder-and-store-the-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!