NSIS 使用技巧

2021-09-02 10:38:40 字數 3491 閱讀 3205

1. 在安裝過程中顯示detailprint除錯資訊

detailprint預設是不顯示的,如果要讓其print的資訊顯示,需在nsis的指令碼起始處新增 showinstdetails show

name "n***ec test"

outfile "n***ec test.exe"

showinstdetails show

section "output to variable"

n***ec::exectostack '"$\makensis.exe" /version'

pop $0 # return value/error/timeout

pop $1 # printed text, up to $

detailprint '"$\makensis.exe" /version printed: $1'

detailprint ""

detailprint " return value: $0"

detailprint ""

sectionend

2. nsis中 +2, +3等跳轉到底是跳轉幾行?

一直對nsis中條件跳轉 +2,+3等比較模糊,即使當時弄清楚了,過段時間又忘了。現做乙個test,將結果記下。

iffileexists d:\sa\test\testdirectory\*.* 0 +1 是判斷testdirectory是否是乙個目錄,若是,則執行0,若不是,則執行+1。

測試條件:不存在testdirectory目錄。

name "test"

outfile "test.exe"

showinstdetails show

section "test"

detailprint "function readconfig"

iffileexists d:\sa\test\testdirectory\*.* 0 +1

detailprint "iffileexists +1"

detailprint "iffileexists +2"

detailprint "iffileexists +3"

detailprint "iffileexists +4"

sectionend

(1)iffileexists d:\sa\test\testdirectory\*.* 0 +1

執行結果為:

iffileexists +1

iffileexists +2

iffileexists +3

iffileexists +4

(2)iffileexists d:\sa\test\testdirectory\*.* 0 +2

執行結果為:

iffileexists +2

iffileexists +3

iffileexists +4

(3)如果將指令碼改為:

name "test"

outfile "test.exe"

showinstdetails show

section "test"

detailprint "function readconfig"

iffileexists d:\sa\test\testdirectory\*.* 0 +3

detailprint "iffileexists +1"

detailprint "iffileexists +2"

detailprint "iffileexists +3"

detailprint "iffileexists +4"

sectionend

預期的執行結果為:

iffileexists +2

iffileexists +3

iffileexists +4

但實際的執行結果卻為:

iffileexists +3

iffileexists +4

可見,空行在編譯後會被濾掉,並不會影響+3所影響的行數。

3. nsis中禁止silverlight自動更新

右鍵單擊microsoft silverlight當前顯示的內容,然後選擇「silverlight配置」。

選擇「更新」選項卡。

選擇以下某個選項:

(0)自動安裝更新(推薦) - 如果選中此選項,您的計算機將自動安裝最新的修補程式、全新的功能以及公升級程式,從而保持計算機處於最新狀態。這是 microsoft silverlight 的預設設定。

(2)從不檢查更新(不推薦) - 您將不會收到有關任何修補程式(包括安全修補程式)、功能或公升級程式的通知。

在企業環境中,管理員可以配置組策略來防止 microsoft silverlight 自動更新。可以建立乙個登錄檔項 hklm\software\microsoft\silverlight,其值名稱為 updatemode,值型別為 dword,給定的值為 0x00000002。此設定將指示計算機不檢查自動更新。

silverlight在安裝後,登錄檔中已存在更新設定的登錄檔項:updateconsentmode.其預設值為:0,自動安裝更新。我們可以將它改為2.

# the silverlight's autoupdate is on by default(0x0). change it to disable mode(0x2)

$ $writeregdword hklm "software\wow6432node\microsoft\silverlight" "updateconsentmode" 0x2

$writeregdword hklm "software\microsoft\silverlight" "updateconsentmode" 0x2

$4. nsis中如何記錄log?

(1)可以通過外掛程式:

比如nsislog plug-in,logex plug-in等。一般logex比較常用。

(2)nsis內建支援log功能

scons nsis_config_log=yes prefix=c:\somewhere install-compiler install-stubs

5. nsis 檢測desktop-experiemce狀態並安裝

winserver 2008的desktop experience不是預設安裝的。可以使用powershell的cmdlet命令檢測他的安裝狀態,若沒有安裝,則安裝之。

1. 可以使用get-command命令加上 萬用字元引數 來獲取feature具體名字。

[img]

2. 使用get-wondowsfeature 可獲取feature的安裝狀態,如果不帶引數則可獲取所有feature的安裝狀態。若該feature已安裝,則其前面會帶有乙個[x]標誌。

[img]

3.在nsis中,可以使用n***ec來執行powershell程式來完成檢測和安裝。

NSIS安裝包製做軟體的常用小技巧

用nsis軟體製作安裝包時總會用到那麼幾個常用的 正因為常用到,自己腦袋又不好記不住,所以就一一記錄下來,時間一長自然也就成好多條了,貼出來與大家分享一下吧。1.如何執行乙個批處理檔案 bat 注 xiaojian.bat為你的檔名 execwait xiaojian.bat 不顯示黑框框 n ec...

使用NSIS製作安裝包 2

乙個完整的安裝應用程式的指令碼。include mui.nsh define mui abortwarning define mui icon contrib graphics icons orange install nsis.ico define mui unicon contrib graph...

使用NSIS將檔案打包exe例項

list 1.安裝nsis v2.36.exe和nisedit2.0b5.exe 2.安裝完成後,開啟nisedit的 檔案 新建指令碼 嚮導 根據嚮導填寫要打包的檔案資訊,新建成功後,會自動生成.nsi檔案。3.在.nsi檔案上右鍵執行 compile nsis script 即可打包成功。備註 ...