您可以创建一个UserInputPanel 并将路径作为变量从用户那里获取。然后你可以在任何你想要的地方使用变量替换。您必须添加一个userInputSpec.xml 文件并定义您自己的面板(任意数量)。要获取目录,请使用<field type="dir" ... >
来自我的应用程序的示例userInputSpec.xml。我在安装程序中包含 mongoDB 并使用它来获取一些设置。
<userInput>
<panel order="0">
<createForPack name="MongoDB" />
<!-- Other settings like port, ip, username, password-->
<field type="staticText" align="left" txt="Select the catalogue where data will be stored." id="staticText.registry.db.data.text" />
<field type="dir" align="left" variable="mongo.data.dir">
<spec txt="Data directory" size="25" set="$INSTALL_PATH\data" mustExist="false" create="true" />
</field>
</panel>
<panel order="1">
<!-- definition of a second panel -->
</panel>
</userInput>
您还需要将userInputSpec.xml 作为资源包含在主安装文件中,并为您在userInputSpec.xml 中定义的每个面板添加UserInputPanel 元素
像这样(在<installation> 元素中:
<resources>
<!-- other resources -->
<res id="userInputSpec.xml" src="userInputSpec.xml" />
</resources>
<panels>
<panel classname="HelloPanel"/>
<panel classname="InfoPanel"/>
<panel classname="LicencePanel"/>
<panel classname="TargetPanel"/>
<panel classname="TreePacksPanel"/>
<panel classname="UserInputPanel"/>
<panel classname="UserInputPanel"/>
<panel classname="InstallPanel"/>
<panel classname="ShortcutPanel"/>
<panel classname="FinishPanel"/>
</panels>
注意两次出现
我在 userInputSpec 中定义了两个面板
确保您的UserInputPanels 出现在InstallPanel 之前,因为您必须在复制文件之前从用户那里获取变量。
这只是我的应用程序中的一个示例。请参阅官方文档以了解我使用的元素和属性的含义。有许多与用户输入相关的功能。