背景
最近公司因为项目需要,需要把web 的项目做成一个window 安装软件给到客户。我在网络上搜索了很多零零散散的教程,大多都不是很详细很全面。在此我进行总结成博文来分享出来,希望帮助到更多的人。
一:下载Inno steup 用于制作windows 上的exe文件Inno steup 工具的使用我就不在这里详细的介绍了,网络上很多的教程可以参考
配置文件供大家参考
; script generated by the Inno Setup script Wizard. ; SEE THE documentATION FOR DETAILS ON CREATING INNO SETUP script FILES! ;软件相关信息描述如下 #define MyAppName "xxxx" #define MyAppChineseName "xxxxx" #define MyAppVersion "v 1.0" #define MyAppPublisher "xxxx公司" #define MyAppURL "http://www.xxxx.xxx" [Setup] ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{D39EB2EE-1636-4DC1-81AC-96D914DAE712} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName=D:Program Files{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes ; Uncomment the following line to run in non administrative install mode (install for current user only.) ;PrivilegesRequired=lowest OutputbaseFilename=tdtavic Compression=lzma SolidCompression=yes WizardStyle=modern SetupLogging=true ;配置中文包 需要ChineseSimplified.isl这个东西,可以百度下,也可以找我要 ,然后放在innosetup的Languages目录下就好 [Languages] Name: "chinesesimp"; MessagesFile: "compiler:Default.isl" ;Name: "chinesesimplified"; MessagesFile: "compiler:LanguagesChineseSimplified.isl" [Files] ;拷贝项目所需文件 Source:".app*";DestDir:"{app}app";Flags:igNoreversion recursesubdirs createallsubdirs ;拷贝mysql jdk tomcat Source:".software*";DestDir:"{app}software";Flags:igNoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files Source:".other*";DestDir:"{app}";Flags:igNoreversion recursesubdirs createallsubdirs [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: quicklaunchicon; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:CreateQuickLaunchIcon}"; Flags: unchecked ;创建打开快捷方式 [Icons] Name: "{group}{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{app}appclient配置工具.exe" Name: "{group}{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" Name: "{commondesktop}{#MyAppChineseName}"; Filename: "{app}appclient配置工具.exe"; Tasks: desktopicon;WorkingDir: "{app}" [INI] ;修改数据库配置文件 Filename:"{app}softwaremysqlmy.ini";Section:"mysqld";Key:"basedir"; String:"{app}softwaremysql" Filename:"{app}softwaremysqlmy.ini";Section:"mysqld";Key:"datadir"; String:"{app}softwaremysqldata" [Run] ;修改服务配置文件 Filename:"{app}initMysqlconf.bat";Description:"正在启动或配置相关程序"; Filename:"{app}install.bat";Description:"正在启动或配置相关程序"; [UninstallRun] Filename:"{app}uninstall.bat";
文件目录说明,如图
app :主要放置代码,和可执行程序
other:服务安装,文件配置以及环境变量配置批处理文件
output: Inno steup的编译输出文件位置
software:放置mysql,jdk, tomcat等服务文件,将所需文件拷贝至当前目录
project.iss: 编译脚本
initMysqlconf.bat
@echo off
set "pth=%~dp0"
set "pth=%pth:=/%"
set "pth=%pth:~,-1%"
(for /f "tokens=1,2* delims=:=" %%a in ('findstr /n .* my.ini') do (
if "%%c" neq "" (
if /i not "%%b"=="basedir" (
if /i not "%%b"=="datadir" (echo,%%b=%%c
) else echo,%%b="%pth%/software/mysqldata/"
) else echo,%%b="%pth%/software/mysql"
) else echo,%%b
))>$
move $ my.ini
install.bat
@echo off
title 软件配置安装中,请不要手动关闭
color 0a
cd /d %~dp0
echo 配置Java、MySQL、Tomcat环境中...
set XXX_APP_HOME=%~dp0%
set XXX_MYSQL_HOME=%XXX_APP_HOME%softwaremysql
set CATALINA_HOME=%XXX_APP_HOME%softwaretomcat
set XXX_JAVA_HOME=%XXX_APP_HOME%softwarejdk
echo 环境变量配置成功echo MySQL安装中...
xcopy "%XXX_APP_HOME%my.ini" "%XXX_MYSQL_HOME%" /y
del "%XXX_APP_HOME%my.ini"
call "%XXX_MYSQL_HOME%binmysqld.exe" install XXX-mysql --defaults-file="%XXX_MYSQL_HOME%my.ini"
call "%XXX_MYSQL_HOME%binmysqld.exe" --defaults-file="%XXX_MYSQL_HOME%my.ini" --initialize
echo 开始启动MYSQL...
sc config XXX-mysql start=auto
net start XXX-mysqlecho Tomcat安装中...
call "%CATALINA_HOME%binservice.bat" install tomcat-XXX
echo 开始启动Tomcat...
sc config tomcat-XXX start=auto
net start tomcat-XXX
echo 安装完成,祝使用愉快~
my.ini
[mysql]
#设置mysql客户端默认字符集
default-character-set=utf8[mysqld]
#设置mysql的安装目录
basedir=D:\test\software\mysql
#设置mysql数据库的数据存储目录,必须是data,或者是\xxx\data
datadir=D:\test\software\mysqldata
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#设置端口
port = 3306
#允许最大连接数
max_connections=200
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB[client]
port=13306
default-character-set=utf8
uninstall.bat
@echo off
title 删除环境配置中,请不要手动关闭
color 0a
echo 删除Java、MySQL、Tomcat中...
echo ??关闭Tomcat
net stop tomcat-xxx
sc delete tomcat-xxx
echo ??关闭MySQL
net stop xxx-mysql
sc delete xxx-mysql
echo 删除完成
文件准备成功就可以开始打包程序了,Inno steup打开project.iss文件,点击绿色三角就可以编译,编译成功后会在output文件夹下生成,
耐心等待,大致15分钟可以生成
安装文件,双击output下的文件就可以安装了
安装效果:
等待安装完成即可
卸载:
控制面板-卸载程序或者直接在暗转目录下双击 uninstall.bat
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)