nsis
nsis download:https://www.filehorse.com/download-nsis/
和nsis打包工具类似的还有inno setup,不过nsis功能更强大,innosetup更方便调试
脚本
nsis脚本*.nsi
代码语言:javascript复制Name HealthSystem
OutFile "HealthSystem.exe"
InstallDir $PROGRAMFILES64HealthSystem
RequestExecutionLevel admin
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
Function .onInit
ClearErrors
ExecShellWait "net stop mysql && sc delete mysql" SW_HIDE #ExecWait执行可以看到控制台
RMDir /r $INSTDIR
Delete $DESKTOPHealthSystem.lnk
FunctionEnd
Section Mysql #拷贝mysql安装部署
SetOutPath $PROGRAMFILES64mysql
SetOverwrite on
File /r /x *.pdb /x *.lib .mysql-8.0.28-winx64*
ClearErrors
FileOpen $0 $PROGRAMFILES64mysqlmy.ini w
FileSeek $0 0 END
IfErrors done
FileWrite $0 "[client]$r$ndefault-character-set=utf8$r$n[mysqld]$r$nport=3306$r$n"
FileWrite $0 "basedir=$"$PROGRAMFILES64/mysql$"$r$n"
FileWrite $0 "datadir=$"$PROGRAMFILES64/mysql/data$"$r$n"
FileWrite $0 "character-set-server=utf8$r$ndefault-storage-engine=INNODB$r$nmax_connections=200$r$n"
FileClose $0
done:
ExecWait "cmd /c cd /d $PROGRAMFILES64mysqlbin && mysqld.exe --install && sc config mysql start=delayed-auto && net start mysql"
SectionEnd
- section,在component页面中作为选项,可以单独选中设置
- function,执行函数
安装nsis后,选择文件右键可以运行nsi脚本,修改文件后,重新加载即可自动运行脚本