Pages

Friday 10 February 2012

How to read command line arguments with NSIS

GetParameters copies all command line arguments into provided variable (as a string). GetOptions extracts value of a specified option within provided parameters string. The following example demonstrates how to get value of command line option "-s":

MyInstaller.nsi:



If we call this installer with following parameters:

"MyInstaller.exe" -t=12 -s=yes -k=abc

...a message box will display text: "s = yes".

GetOptions is not case sensitive so if we called it with "-S", the result would be the same. GetOptionsS is a case sensitive form of this function.

2 comments:

  1. Buenas tardes,
    Estoy realizando el mismo ejemplo en mi NSIS 2.16, pero me muestra un error "Invalid command: ${GetParameters}"

    Tiene que ver algo la versión??

    ReplyDelete
  2. Hola! ¿Ha incluido "FileFunc.nsh"? [http://nsis.sourceforge.net/Include/FileFunc.nsh]

    ReplyDelete