NSIS官网(Nullsoft Scriptable Install System)是一个开源的 Windows 系统下安装程序制作程序。它提供了安装、卸载、系统设置、文件解压缩等功能。NSIS 通过它的脚本语言来描述安装程序的行为和逻辑的。
1.1 下载安装文件
下载地址: https://sourceforge.net/projects/nsis/files/
1.2 日志模块, 用于卸载
NSIS 的 log 模块 nsis-3.05-log.zip, 覆盖 NSIS 文件夹中同名文件即可
1.3 插件: 检测进程
安装/卸载时: 检测进程是否运行, 是则结束该进程; 否继续安装/卸载
NSIS官网下载插件 NsProcess_plugin
下载后, 放在下面 Plugins里面:
C:\Program Files (x86)\NSIS\Plugins\x86-ansi 和 C:\Program Files (x86)\NSIS\Plugins\x86-unicode
!include "LogicLib.nsh"
!define PROCESS_NAME "xxx.exe"
;省略中间很多....
; ------ 安装前检查程序是否正在运行
Section ""
nsProcess::_FindProcess "${PROCESS_NAME}"
Pop $R0
${If} $R0 = 0
nsProcess::_CloseProcess "${PROCESS_NAME}"
Pop $R0
nsProcess::_Unload
Sleep 500
${EndIf}
SectionEnd
4. 带向导的脚本编辑器 HM NIS EDIT
官网: http://hmne.sourceforge.net
下载: nisedit2.0.3.exe
5. 安装程序完成后后台运行
; ------ 提示安装完成并打开
Function .onInstSuccess
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) 安装完毕"
ExecShell "" "$INSTDIR\${PROCESS_NAME}"
FunctionEnd
具体怎么写脚本参考 https://blog.csdn.net/ly305750665/article/details/60785098