Windows installation package production guide - the use of Advanced Installer

1 Introduction

  Recently, I need to make an installation package for windows. It is said that Advanced Installer is more powerful, so I use it to make an installation package. After exploring a small amount of information on the Internet and the simple documents on the official website, I finally produced a usable installation package, which is recorded here for reference only.

     Advanced Installer version: Advanced Installer 11.0, the latest version is 13.1, but similar.

 

2. Installation package production

2.1 New construction

  Since we want to be able to customize some installation interfaces ourselves, we choose the Professional version, the language is Chinese, and then create the project:

 

2.2 Product Details

  Fill in the basic information of the product, including name, version, company, etc.:

 

2.3 Installation parameters

  After filling in the product details, select the installation parameters on the left. We mainly look at the contents of "Installation Folder" -> "Application Folder" in the right panel: "[ProgramFilesFolder][Manufacturer]\[ProductName]", which indicates the default installation path during installation:

    [ProgramFilesFolder] 表示 C:\Program Files(x86)

    [Manufacturer] represents the company name, which is the TestCompany filled in in 2.2

    [ProductName] represents the product name, which is the TestApp filled in in 2.2

  Then the default installation path displayed is "C:\Program Files(x86)\TestCompany\TestApp".

 

2.4 Operating Environment

  The digital signature, update program, upgrade and authorization on the left are not the focus of attention for the time being, so I will skip it first. Advanced Installer provides very good support for running environment, we can choose any environment we need. After the installation package is made, the dependent environment will be automatically run when the installation package is run:

 

2.5 Files and folders

  The startup conditions and merge modules on the left are not the focus of attention for the time being, so I will skip them first. The files and folders are our project files, you can choose to create or add:

  After adding the file, it might look like this:

 

2.6 Dialog

  由于我们希望能够自制对话框,需要切换成开发版。点击“项目”->"选项",在弹出的界面中,选择“项目类型”->“开发版”

  假设我们要在选完安装路径后新增一个对话框,那么在右侧的FolderDlg右键,选择“新建对话框”:

  让我们在对话框上添加两个输入控件,一个希望是必填的,另一个希望是选填的。注意右侧的属性名称,它是实现“必填”功能所必须关注的变量:

  那么什么时候对输入框中是否有输入进行判断呢?应该是在用户点击“下一步”的时候。所以选择“下一步”,关注下方的“发布事件”:

  我们需要新建一个事件,这个事件的作用是:如果必填项没有内容,那么弹出一个对话框来提示用户需要输入。想要做到这一点,点击“新建”。在新弹出的界面中选择“显示特定子对话框”,勾选“显示整个条件”,然后再条件中填写“NOT EDIT_1_DROP”。EDIT_1_DROP这个变量就是之前必填输入控件,前面加NOT的意思就是,如果这个输入控件没填内容,就弹出子对话框。

  点击“确定”就可以了。

 

2.7 注册表

  我们已经限定了必填项和选填项,但是又有疑问了,用户填写的内容保存在哪呢?我们能从什么地方读到这些变量呢?

  这时候注册表就派上用场了,把用户输入的内容关联到注册表的相应变量中不就搞定了吗?Advanced Installer恰恰提供了这种机制。

  在左侧选择“注册表”,我们可以看到右侧的注册表中已经有了两个变量Path和Version,分别是安装路径和版本。

  然后在右侧的“[ProductName]”右键弹出菜单,点击“新建值”,

  在弹出的窗口中,“名称”填写一个希望在注册表中被看到的名称,比如“RequiredValue”。再点击“属性”,选择之前自定义的对话框中的控件名称(就是咱们)。

  创建好后如下:

 

2.8 自定义操作 

  梳理下刚刚的流程,用户在输入框中输入了内容,点击下一步后,这些内容被保存到注册表的相应位置。然后这些变量要用起来了,一种可能的场景就是,在安装结束时,我希望去执行自定义的脚本,这个脚本会从注册表中读取这些变量,并基于这些变量对项目文件做初始化。

  那么执行自定义脚本就需要Advanced Installer的“自定义操作”来帮忙,在左侧选择自定义操作,然后在菜单栏单击“新建自定义操作向导”:

  在弹出的面板中点击“下一步”,然后根据自己要执行的脚本或文件选择不同类型:

  然后点击下一步,根据情况选择:

  然后点击如图按钮选择源文件:

  然后下一步,根据需要选择,再下一步,完成。完成后,在右侧界面中可以选择必要的选项,比如说隐藏窗口,或者是以管理员身份运行等。

 

2.9 构建和运行

  如图,点击1呢是构建安装包,构建的目录默认是在“我的文档\Advanced Installer\Projects\TestApp\setup-SetupFiles"中,其中TestApp是项目名称。

  点击2呢是构建并运行安装包,用作测试这个安装包是否可用。

 

3 总结

  至此我们打出了windows 32位的有自定义界面的并能调用特定脚本的包。Advanced Installer还提供了各种强大功能,比如说能打出x86\x64混合包等,有待进一步探索。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326568323&siteId=291194637
Recommended