NSIS最简单的软件打包示例,制作exe安装包

141次阅读
没有评论

共计 975 个字符,预计需要花费 3 分钟才能阅读完成。

从简单到完整,Liam平平带你一步步制作完美安装包, 万事开头难。

第一课:制作一个安装包,运行后将安装包中文件安装到指定位置。

一、 下载安装NSIS

官方下载地址:https://nsis.sourceforge.io/Download

二、编写脚本

  1. 新建一个脚本文件, 如:test1.nsi
; The name of the installer
Name "HelloLiam"

; The file to write
OutFile "hello_liam_setup.exe"

; Request application privileges for Windows Vista
RequestExecutionLevel user

; Build Unicode installer
Unicode True

; The default installation directory
InstallDir $PROGRAMFILES64\HelloLiam

;Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
; Pages

Page directory
Page instfiles

;--------------------------------
; The stuff to install
Section "" ;No components page, name is not important
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  ; Put file there
  ;File HelloLiam.exe ;add a file.
  File /r "InstallFiles\*.*" 
SectionEnd ; end the section

 

  1. 准备需要打包的文件,示例放在脚本同目录的InstallFiles文件夹下

NSIS最简单的软件打包示例,制作exe安装包

需要打包的文件:

NSIS最简单的软件打包示例,制作exe安装包

  1. 编辑脚本:推荐使用VS Code安装代码高亮插件。

三、 运行脚本生成安装包

  1. 打开NSIS软件

NSIS最简单的软件打包示例,制作exe安装包

  1. 打开示例test1.nsi

NSIS最简单的软件打包示例,制作exe安装包

  1. 生成exe安装包

NSIS最简单的软件打包示例,制作exe安装包

四、测试安装

  1. 直接点击测试安装,或手动运行exe安装包
  2. 路径选择界面:

NSIS最简单的软件打包示例,制作exe安装包

  1. 安装完成界面

NSIS最简单的软件打包示例,制作exe安装包

  1. 安装后的效果

NSIS最简单的软件打包示例,制作exe安装包

End

欢迎查看后期教程:

  1. 创建快捷方式。
  2. 创建卸载程序。
  3. 界面美化。
  4. 判断是否正在运行。
  5. 判断并安装VC运行库。
正文完
 
admin
版权声明:本站原创文章,由 admin 2022-07-19发表,共计975字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码