Skip to content
⌘ NSIS Forum Archive

MUI + InstType and silent install

4 posts

dwatrous#

MUI + InstType and silent install

I have created an installer that uses MUI and has several InstTypes. It works great.

I now have the need to automate the deployment across several hundred hosts and would like to use the silent install option, but I'm having trouble.

I was hoping that I could just run it from the command line like this:
myinstaller.exe /S /InstType="Some Platform"
That doesn't work. The correct sections are not selected.

Can someone tell me how to pass the InstType in on the command line?
MSG#
It's all in the manual: http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.11

You can use the macros in sections.nsh to toggle (enable/disable) sections, depending on the paramaters supplied to the installer. You can do this in the .onInit function.
Mupp#
select Install Type from cmd line

I have prepared project using InstType, this works fine...but how can you set(select) InstType from command line? is this possible?

yes i could GetParameters and GetOptions...but that kinda defeats the full convenience of using InstType.

InstType(Install Type) should be able to be set from cmd line as a built-in switch.

why build a bridge that goes 99% across the river, you need 100%
Anders#
Originally Posted by Mupp View Post
why build a bridge that goes 99% across the river, you need 100%
There is a issue with languages here. Languages are not loaded in .onInit so a automatic solution is not possible for all languages.

With a little work on your part you can do it, all you need is GetOptions and SetCurInstType .

If you only have a single language or only care about the default language:

!include LogicLib.nsh
!include FileFunc.nsh
Function SetInstTypeByName
Exch $3
Push $1
Push $2
ClearErrors
StrCpy $1 0
loop:
    InstTypeGetText $1 $2
    ${If} $2 != ""
    ${AndIf} $2 == $3
        SetCurInstType $1
    ${EndIf}
    IntOp $1 $1 + 1
    IfErrors "" loop
Pop $2
Pop $1
Pop $3
FunctionEnd
Function .onInit
${GetParameters} $R0
${GetOptions} $R0 /INSTTYPE= $0
Push $0
Call SetInstTypeByName
FunctionEnd 
With multiple languages you need to do some manual labor. I'm sure you can automate most of it with clever use of the pre-processor and a macro for InstType creation.