天天看點

【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語

文章目錄

  • 1、NSIS
    • 1.1 軟體簡介
    • 1.2 下載下傳安裝
    • 1.3 代碼示例
  • 2、Inno Setup
    • 2.1 軟體簡介
    • 2.2 下載下傳安裝
    • 2.3 代碼示例
  • 結語

1、NSIS

官網位址:

https://nsis.sourceforge.io/Main_Page

最新版本:NSIS 3.08,September 25, 2021

【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語

NSIS(Nullsoft Scriptable Install System)是用于建立 Windows安裝程式的專業開源系統。它被設計為盡可能小而靈活,是以非常适合網際網路分發。

NSIS (Nullsoft Scriptable Install System) 是 Windows 下的一個安裝程式建立工具,它允許程式員來建立這樣的安裝程式。 它釋出于一個開源的協定并且對于 任何使用者來說都是完全免費的。

【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語

1.1 軟體簡介

  • NSIS 建立的安裝程式能夠安裝、解除安裝、設定系統設定、解壓檔案等等。
  • 因為它基于腳本檔案,你可以完全的控制安裝程式的每一部分。 腳本語言支援變量、函數、字串操作,就像一個普通的程式語言一樣 - 但是設計來建立安裝程式。
  • 即使有那麼多的特性, NSIS 仍然是最小的安裝程式系統。在預設選項下,它僅增加了 34 KB 的開銷。
  • 你可以在(ZLib, BZip2, LZMA)這三種完整的壓縮方法中選擇其一。新的 LZMA 壓縮具有比其它通用壓縮方法更好的效果。而且你不需要大塊的外殼釋放文檔子產品或其它的應用程式。該壓縮方式已經包含在那 34 KB 的額外開銷裡。
  • 不像其它的安裝系統僅能基于檔案清單和系統資料庫操作來建立安裝程式,NSIS 有一個強大的腳本語言。該腳本語言設計來專門制作安裝程式并有可以幫助你執行任何安裝任務的指令。你可以很容易的添加自定義邏輯和處理不同的更新、版本檢測等。
  • NSIS 可以由能和安裝程式對話的插件來擴充。他們可以由 C, C++, Delphi 或其他語言并且可以用來執行安裝任務或擴充安裝程式界面。使用這些插件你隻需要一行代碼。
  • NSIS 具有體積小、速度快和高效率的特點。當其它安裝程式動辄需要幾百 KB 或好幾 MB 的安裝程式資料,而一個具有完整功能的 NSIS 安裝程式僅占用了 34 KB 的額外開銷。

1.2 下載下傳安裝

https://nsis.sourceforge.io/Download

【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語
【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語

1.3 代碼示例

  • 腳本示例:
; example1.nsi
;
; This script is perhaps one of the simplest NSIs you can make. All of the
; optional settings are left to their default settings. The installer simply 
; prompts the user asking them where to install, and drops a copy of example1.nsi
; there. 
;
; example2.nsi expands on this by adding a uninstaller and start menu shortcuts.

;--------------------------------

; The name of the installer
Name "Example1"

; The file to write
OutFile "example1.exe"

; Request application privileges for Windows Vista
RequestExecutionLevel user

; Build Unicode installer
Unicode True

; The default installation directory
InstallDir $DESKTOP\Example1

;--------------------------------

; 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 example1.nsi
  
SectionEnd

           

2、Inno Setup

官網位址:

https://jrsoftware.org/isinfo.php

https://github.com/jrsoftware/issrc

最新版本:innosetup-6.2.1.exe,2022-04-14

【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語

2.1 軟體簡介

Inno Setup 是Jordan Russell 和 Martijn Laan 為 Windows 程式提供的免費安裝程式。Inno Setup 于 1997 年首次推出。
  • 支援自 2006 年以來的每個 Windows 版本,包括:Windows 11、Windows 10、Windows 10 on ARM、Windows Server 2019、Windows Server 2016、Windows 8.1、Windows 8、Windows Server 2012、Windows 7、Windows Server 2008 R2、Windows Server 2008和 Windows Vista。(不需要服務包。)
  • 廣泛支援在 64 位版本的 Windows 上安裝64 位應用程式。x64、ARM64 和 Itanium 架構均受支援。
  • 檔案安裝:包括對“deflate”、bzip2 和7-Zip LZMA/LZMA2 檔案壓縮的​​內建支援。安裝程式能夠比較檔案版本資訊、替換正在使用的檔案、使用共享檔案計數、注冊 DLL/OCX 和類型庫以及安裝字型。
  • 用于進階運作時安裝和解除安裝定制的內建 Pascal 腳本引擎選項。
  • 是的,它可以完全免費使用,即使在部署商業應用程式時也是如此。

2.2 下載下傳安裝

  • (1)版本6+

    https://jrsoftware.org/isdlold.php#6

    【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語
    【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語
    【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語
  • (2)版本5+

    https://files.jrsoftware.org/is/5/

    【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語
    【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語
    【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語

2.3 代碼示例

  • 腳本示例:
; -- Example1.iss --
; Demonstrates copying 3 files and creating an icon.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

           

結語

如果您覺得該方法或代碼有一點點用處,可以給作者點個贊,或打賞杯咖啡;

╮( ̄▽ ̄)╭

如果您感覺方法或代碼不咋地

//(ㄒoㄒ)//

,就在評論處留言,作者繼續改進;

o_O???

如果您需要相關功能的代碼定制化開發,可以留言私信作者;

(✿◡‿◡)

感謝各位童鞋們的支援!

( ´ ▽´ )ノ ( ´ ▽´)っ!!!

【夏蟲語冰】開源軟體安裝包制作工具(NSIS,Inno Setup)1、NSIS2、Inno Setup結語