3

我有一个 NSIS 脚本,它要求用户提供安装目录,但我想在新页面上要求用户再提供一个临时目录。有没有一种方法可以让我使用 nsDialogs 添加一个新页面,它指定一个临时目录,例如

C:\temp

并且还让他们选择不同的目录,然后将所选目录的值存储在变量中

4

2 回答 2

5

如果你只想要一个类似于安装目录页面的对话框,你不需要自己做一个对话框:你可以调用MUI_PAGE_DIRECTORY两次。取自现有设置的示例:

!insertmacro MUI_PAGE_DIRECTORY ; <= it will store the selected directory into $INSTDIR

;second directory selection
!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install the database."
!define MUI_DIRECTORYPAGE_TEXT_TOP "The installer will install the database(s) in the following folder. To install in a differenct folder, click Browse and select another folder. Click Next to continue."
!define MUI_DIRECTORYPAGE_VARIABLE $DbInstDir ; <= the other directory will be stored into that variable
!insertmacro MUI_PAGE_DIRECTORY

如果您只需要在某些情况下显示第二个目录选择,您可以添加回调到第二个页面

!define MUI_PAGE_CUSTOMFUNCTION_PRE some_custom_function

在该回调中,测试是否需要显示目录选择。如果没有,调用Abort将跳过该页面。

于 2013-10-07T09:55:35.460 回答
0

以防万一您不知道这一点:NSIS 安装程序可以创建(或将,如果使用插件)一个临时文件夹。您可以使用InitPluginsDir命令对其进行初始化

于 2013-10-07T21:08:23.343 回答