Search code examples
installationinno-setup

Passing Custom command line parameter in Inno Setup to progams executable


I am preparing an Inno Setup installer and want to allow the user to pass parameters like testparam=abc along with the setup.exe. The value of testparam should be forwarded to the application.exe in the run section.

Something like:

MySetup.exe /testparam=abc .

I followed the instructions from Is it possible to accept custom command line parameters with Inno Setup and Custom command line parameter in Inno Setup with default value so I can pass build configuration but it still receive the error:

Unrecognized [Setup] section directive at the line below in the [Setup] section.

This is a part of my iss file: at the beginning:

> #DEFINE myparam ""
> 
> [Setup]   
> myparam = {param:testparam|Debug}
> 
> [Run]
> Filename: {app}\{#AppName}.exe; Flags: runhidden; Parameters:"/internalParam ""{myparam}""";

The /internalParam should receive the value myparam (in this case "abc") and should be handled in the application.

I guess I am missing something and maybe someone can point me to the right direction. Thank you.


Solution

  • The error message is literally correct. You can't "make up" [Setup] section directives. However, you could do this, I think:

    [Run]
    Filename: "{app}\{#AppName}.exe"; Flags: runhidden; Parameters:"/internalParam ""{param:internalParam}"""