1

I have a program built with WPF in C#. I used Inno Setup to build an installer for the program.

If I run my installer, I put in the ability to launch the program when finishing the installer. See below: Launch from installer

This works without issue. My application is launched and begins its startup process as expected.

However, under normal operation, a user would not install the program every time they want to run it. Instead, they would go into the start menu and type in the ApplicationName and run it. When I run the program this way, I get the following error:

Value canot be null.
Parameter name: section

Start menu error.

I have tried starting from scratch by ensuring the program is not installed, running the installer, unchecking the box, and running the program from the start menu. The error persists. If, from here, I run the installer and leave the box checked, the program starts like normal.

I do have a portion in my Inno Setup file that provides command line args as seen here (with some components in all caps to hide actual data):

[Run]
Filename: "{app}\{#ExecutablePath}\{#MyAppExeName}"; \
    Description: "Launch APPNAME"; \
    Parameters: "APPNAME {userappdata}\{#MyAppName}\FOLDERNAME ARG"; \
    Flags: runascurrentuser shellexec skipifsilent nowait postinstall

The only thing I can think of is that these only get passed in when the program is launched from the installer and not from the Start menu. However, as I understand the Parameters: property, this is not the case.

I have only written installers for far more basic programs in the past. This program has a large number of projects and files associated with it along with requiring command line arguments. Is there anything obvious I am missing? I do not know what to try next as I cannot find instances of similar behavior online.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

2

The Parameters in the [Run] section indeed apply only when running the application from the installer. They have no effect on the [Icons]. Those have their own Parameters parameter.

[Icons]
Name: "{autoprograms}\My Program"; Filename: "{app}\MYPROG.EXE"; \
    Parameters: "APPNAME {userappdata}\{#MyAppName}\FOLDERNAME ARG"

Though your application should not fail completely, when started without parameters.


Regarding the runascurrentuser flag: That does not have an easy mapping in [Icons]. Because, in general, applications should not be run with Administrator privileges. If they need it, it's usually a sign of a bad design. For details, solutions, workarounds and hacks, see Application does not work when installed with Inno Setup.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992