2013-10-05 54 views
0

我正在創建一個使用NSIS的安裝程序,其中包含一些內置頁面和一些自定義頁面。在這一點上,我只想在安裝過程中通過命令行來顯示使用安裝的自定義頁面。可以做到?命令行選項和跳過頁面

!include "MUI.nsh" 
!include nsDialogs.nsh 

OutFile "myCustomPage.exe" 
var installmethod 
Page Custom MyCustomPage 
Page Custom MyCustomPage1 
Page Custom MyCustomPage3 

Function MyCustomPage 
nsDialogs::Create 1044 

    nsDialogs::Show 

FunctionEnd 
Function MyCustomPage1 
nsDialogs::Create 1044 

    nsDialogs::Show 

FunctionEnd 
Function MyCustomPage3 
nsDialogs::Create 1044 

    nsDialogs::Show 
FunctionEnd 
Section Dummy 
SectionEnd 

在上述例子中我有3個pages.I要在正常安裝到僅示出了兩頁MyCustomPage和MyCustomPage3。如果一個命令行(特定命令行)通過,那麼在安裝過程中應該出現所有3個頁面。它可以完成嗎?

回答

1
!include FileFunc.nsh 
!include LogicLib.nsh 

Page Custom MyPageCreate 

Function MyPageCreate 
${GetParameters} $0 
ClearErrors 
${GetOptions} "$0" "/ShowSpecial" $1 
${If} ${Errors} 
    Abort ; Skip page 
${EndIf} 
nsDialogs::Create 1044 
nsDialogs::Show 
FunctionEnd 
+0

對你如何做你所做的一些解釋會有所幫助。 – cHao

+0

你好安德烈斯。請檢查我的答案。你已經使用getoption等。我的方法有問題嗎?它正常工作。但我的方法是高效和適當的? –

+0

如果你永遠不會支持其他參數,不關心報價,那麼你的版本是OK ... – Anders

0

如果命令行選項爲「a」,則下面的代碼跳過頁面MyCustomPage1。

!include "MUI.nsh" 
!include "FileFunc.nsh" 
!include nsDialogs.nsh 
!insertmacro GetParameters 

OutFile "myCustomPage.exe" 
var installmethod 
Page Custom MyCustomPage 
Page Custom MyCustomPage1 
Page Custom MyCustomPage3 

Function MyCustomPage 
    nsDialogs::Create 1044 
    nsDialogs::Show 
FunctionEnd 

Function MyCustomPage1 
    ${GetParameters} $R0 
    ${If} $R0 == 'a' 
     abort 
    ${EndIf} 
    nsDialogs::Create 1044 
    nsDialogs::Show 
FunctionEnd 

Function MyCustomPage3 
    nsDialogs::Create 1044 
    nsDialogs::Show 
FunctionEnd 

Section Dummy 
SectionEnd