exe packaging tool: introduction to advanced installer (1)

foreword

In recent years, web services have gradually moved towards cloud deployment + browser-based and de-app-based. However, exe installation still plays a pivotal role, and its benefits are self-evident. After getting the exe installation package, it can basically be installed and operated by fools. Very convenient.

Business scene

  1. After completing development tasks through various IDE / QT / C# / Java and other development tools/languages, you will generally get three types of files, jar, exe, and tomcat/jboss+mysql+.. service applications.

  1. Sometimes it is necessary to deploy these applications on a brainless stand-alone machine and show them to customers. At this time, it is a good choice to package the applications as exe.

  1. Benefits of packaging as exe : Click the exe installation package to deploy with one click = automatic registration service + automatic start service + automatic generation of desktop shortcuts + automatic creation of shortcuts such as " open program, uninstall program " in the start menu, making the program more professional .

Based on advanced installer 19.7 + windows10, this article packs tomcat+mysql+jdk+elasticSearch into exe, so that friends who don't know the software can make their own exe.

Tool Type

There are many kinds of packaging tools on the market, including install4j , exe4j , launch4j , advanced installer , etc. If you want to know more types of packaging tools, click to enter , and I will not expand too much here. This article focuses on advanced install.

download link

Official website download address: https://www.advancedinstaller.com/download.html , v20.3.2

1. Results display

1. After clicking to install the exe package, it will automatically start tomcat, mysql, ES services, and automatically open the login interface;
2. Generate a shortcut to log in/start the service on the desktop (to prevent customers from accidentally closing the black service window);
3. On Windows In the start menu of the system, create a demoExe folder (customized project name), which contains shortcuts for logging in, starting services, and uninstalling services.
  1. Installation process

  1. Show results

The corresponding shortcut is generated on the desktop

Start menu, generate corresponding shortcuts

2. Operation steps

2.1 New construction

As shown in the figure below, click "File--New" in the upper right corner of the software in turn

Select "Enterprise Edition", "Language" and click Create.

Tip: If you want to experiment by yourself, you can click on the professional version, and the functions and enterprise version are slightly deleted.

2.2 Fill in the basic information of the software

The first half of the information is required, and the default installation directory will read the information, so it is recommended to use letters or English.

The "Product Support Information" in the middle can be filled in as needed, it is not particularly important

The "License" at the bottom is optional, and of course it can be selected again in the following dialog box. The difference between the two is that selecting "License" on this page will only be displayed on the installation interface, and will not ask whether to agree.

反之,在对话框中选取的“许可证”会在安装界面,刻意要求必须同意协议许可,才可以继续安装。

注:这个“许可证”的格式是rtf的,可粗略的认为是word格式的。

2.3 添加所需打包文件

如下图所示,通过添加文件夹的方式,把需打包程序添加进来,个别文件也可以单独以文件的方式单独添加进来。

添加后的效果,基本是下面这个样子。

注:这里使用的mysql和tomcat都是绿色免安装的版本!

2.4 配置快捷方式

2.4.1 配置桌面快捷方式

具体,配置什么类型的快捷方式,根据你的需求来。程序安装完毕后,这些快捷方式会自动出现在桌面。

说明:在配置界面,可以修改快捷方式名称和图标。

需要注意的是,配置的时候,以管理员的身份运行,是可选的

2.4.2 配置开始菜单中的快捷方式

和上面创建快捷方式,几乎一样,区别是创建的位置不同,创建快捷方式前,建议先创建一个文件夹(可以是中文名称),然后在文件夹中创建快捷方式,里面一般包含一个登录的、一个卸载的、启动服务的快捷方式(可选)

需要说明的是,卸载的快捷方式,如上图所示,选择卸载就可以了,也是比较省事儿的。

如果创建的快捷方式选择“已安装程序”,一般指向的是exe或者bat文件,比如你想通过此快捷方式指向bat,bat里写启动某些服务的代码。

2.5 新建环境变量(可选)

环境变量,一般是JAVA_HOME、path一类的,你安装包中包含的有JRE或jdk,配置的环境变量JAVA_HOME需要指向上面添加文件夹中的jre或jdk。

此时,就涉及了一个路径的问题,如下图所示,本案例中已添加打包文件的目录结构

此时的JAVA_HOME就需要配为 [ProgramFilesFolder][Manufacturer]\[ProductName]\RCA-Service\jdk

至于,[ProgramFilesFolder][Manufacturer]\[ProductName]是怎么来的,它来自于下面2.6中的安装参数,也是默认的,三个变量分别是文件夹名称(默认是program files(x86))、发布人(填写软件详信息时配的)、工程名称。

下面是安装后,自动生成的目录

2.6 安装参数

再次提示:该界面的[ProgramFilesFolder][Manufacturer]\[ProductName]变量会在配置环境变量时用到。

拓展:版本信息变量为 [|ProductVersion] ,此变量在安装创建界面可以动态调用。

2.7 对话框设置

2.7.1 自定义公司信息、版本信息、联系方式等

发挥你的想象,填写一些需要的内容

注:版本信息,可以写固定值,或变量[ProductVersion],如下图所示

2.7.2 许可证

左侧“对话框”-->右侧“首次安装”(鼠标右键),“添加对话框”

选择LicenseAgreementDlg

选择准备好的rtf格式的协议(rtf和word格式类似)

单选按钮,默认是哪一个被选中的,由你来决定,只需要点击单选图标,在右侧配置真(true)就可以,如下图所示:

2.7.3 安装结束后启动服务(可选)

如下图所示,如果把对钩,配置为true,并指向指定的bat或exe文件,就会达到你想要的效果。

当然这个是有前提的,也就是你在bat脚本中注明了要启动哪些服务,且这些服务已经被你打包好的服务,或者被你主动注册的某个服务,如mysql服务。

注:bat脚本的编写格式,会在底部附录中提供,自行参考!

勾选后,下方指定要启动服务,所对应的bat或exe文件,据此达到你想要的效果!

2.8 注册服务(可选)

最终这些注册成功的服务,会显示在windows服务列表中,你可以win+r键,输入services.msc,看到这些服务(即使exe安装失败了,在你确认回滚之前,仍然可以看到你注册的这些服务或其中一个服务,报错安装程序回滚后,这些注册的服务会被自动清除)。

2.9 注册注册表(可选)

依次点击“注册表-->current user当前用户-->Software”鼠标右键,新建项

名称:Microsoft\Windows\CurrentVersion\Run

修改后自动生成下面的目录结构

然后,再在右侧空白处,鼠标右键,新建值

文件,分别指向你的exe比如mysql或其他bat什么的(目前不是很确定bat是否可行),步骤是这样的,我的注册貌似没起到效果!

2.10 安装风格选

这里就不用过多介绍了,一点便通,好理解,可以找一个自己喜欢的风格,当做主题。

2.11 构建并启动生成exe文件

2.11.1 选择输出文件类型和位置

2.11.2 构建并生成exe

如下图所示,点击产品信息后,再依次点击构建-->运行,这个过程需要稍微等待一会儿。

最后,打开输出文件夹,可以找到生成的exe文件

三、遗留问题

在注册服务后,安装exe时,一直提示如下错误,导致服务实际上无法被成功注册,暂且没搞明白是哪里的问题,后续计划换其他版本试一下,当然有了解的小伙伴,也可告知一下!

说明:服务如果能注册成功,就不用以黑色窗口启动tomcat、ES了,而是以后台服务的方式启动,会比较nice。

四、鸣谢

应用程序安装包制作工具简介

https://blog.csdn.net/zxia1/article/details/6124550

advanced installer 使用常见问题整理

https://blog.csdn.net/frozleaf/article/details/84195026

Windows注册服务的两种方式,并设置服务开机自启

https://blog.csdn.net/qq_41587516/article/details/112485426

advanced installer保姆级做包教程

https://blog.csdn.net/qq_41750806/article/details/122166802

总结

本文重点介绍了把mysql+tomcat+jdk+elasticsearch打包为exe的大概操作步骤,还有一些需要注意的细节以图片方式,均有标注。
由于这个软件的功能确实很强大,比如“先决条件”、“启动条件”这些很实用的功能,本文并没有介绍。后期随着研究的深入,会慢慢补充。
如果你打包的是其他的,比如jar包,可以参考上方的保姆教程。

尾言

如果你有什么想法,可以点赞留言,共同探讨,最后把bat脚本以附录的形式,便于需要的小伙伴学习参考!

附录

start-RCA-3.bat 说明:内容略有改动,不影响阅读,替换为你自己的就可以了。

稍微有linux基础和java基础的都能大概看懂,有疑问,可留言探讨!

@echo off
if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0
bcdedit >nul
if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin)
:UACPrompt
%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
exit /B
:UACAdmin
cd /d "%~dp0"


cd %~dp0mysql\bin
echo %~dp0mysql\bin
::start startMysqlServer.bat
start /min mysqld.exe --console


@set JAVA_HOME=%~dp0\jdk
@set CLASS_PATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
@set PATH=%PATH%;%JAVA_HOME%\bin

cd /d "%~dp0"
cd %~dp0elasticsearch\bin
start /min elasticsearch.bat


cd %~dp0tomcat\bin
start /min startup.bat
echo tomcat is started
ping /n 30 127.1 >nul
start explorer  "http://localhost:8080/test/login"


exit

附注

猜你可能喜欢

1、RHEL7/8、CentOS7/8的下载和配置

Guess you like

Origin blog.csdn.net/xp871038951/article/details/129373608
Recommended