NSIS最簡單的軟體打包示例,製作exe安裝包
從簡單到完整,Liam平平帶你一步步製作完美安裝包, 萬事開頭難。
第一課:製作一個安裝包,執行後將安裝包中檔案安裝到指定位置。
一、 下載安裝NSIS
官方下載地址:
https://
nsis。sourceforge。io/Dow
nload
二、編寫指令碼
新建一個指令碼檔案, 如:test1。nsi
準備需要打包的檔案,示例放在指令碼同目錄的InstallFiles資料夾下
需要打包的檔案:
編輯指令碼:推薦使用VS Code安裝程式碼高亮外掛。
; 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
指令碼說明:
Name “HelloLiam” 指定軟體名稱
OutFile “hello_liam_setup。exe” 指定輸出的exe安裝包名稱
InstallDir $PROGRAMFILES64\HelloLiam 指定安裝位置C:\Program Files\HelloLiam
RequestExecutionLevel admin 給安裝包新增管理員許可權
Page directory 指定安裝程式顯示的介面
File /r “InstallFiles\*。*” 指定需要打包的檔案
三、 執行指令碼生成安裝包
開啟NSIS軟體
開啟示例test1。nsi
生成exe安裝包
四、測試安裝
直接點選測試安裝,或手動執行exe安裝包
路徑選擇介面:
安裝完成介面
安裝後的效果
End
歡迎檢視後期教程:
建立快捷方式。
建立解除安裝程式。
介面美化。
判斷是否正在執行。
判斷並安裝VC執行庫。