IT researcher
IT researcher

Reputation: 3304

Command line option and skip page

I am creating a setup using NSIS which include some builtin pages and some custom page also.In that i want to show a custom page using install only if a command line is passed during install.How it can be done?

Example

!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

In the above example i have 3 pages.I want to shown only two pages MyCustomPage and MyCustomPage3 during normal install. If a command line(specif command line) passed then all 3 pages should appear during installation.how it can be done?

Upvotes: 0

Views: 130

Answers (2)

IT researcher
IT researcher

Reputation: 3304

Below code skips page MyCustomPage1 if the command line option is "a".

!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

Upvotes: 0

Anders
Anders

Reputation: 101764

!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

Upvotes: 1

Related Questions