Exec not working in NSIS installer
Asked Answered
N

2

4

I am new to NSIS i am trying to execute an executable while installation similar to pre request. I tried the below code which copies the exe to the installation path but it is not executing it.

Section "example" example
  SetOutPath "$INSTDIR"
  File "setup.exe"
  Exec "$INSTDIR\setup.exe"
  BringToFront
SectionEnd 
Negate answered 5/6, 2012 at 12:25 Comment(0)
A
8

The answer from Seki is mostly correct, I'd just like to add that the correct syntax for Exec/ExecWait is always Exec '"c:\path\app.exe" param1 "par am2" param3'

Parameters are of course optional but the path to the app should always be quoted, not just because in your case where $INSTDIR could contain spaces but at least on Win9x it will fail no matter what if you don't quote (According to the NSIS manual)

If the spaces/lack of quotes is not the issue then there are a couple of other things you might want to look into:

  • $OUTDIR is the working directory for the new process (SetOutPath sets this)
  • Missing dll's etc (Check with Process Monitor)
Alissaalistair answered 5/6, 2012 at 15:27 Comment(1)
Mmmh, thanks for pointing that double-quotes are always mandatory. In the help of the latest release, it is not that obvious as it states at 4.9.1.2 "[...]Note, if the command could have spaces, you should put it in quotes to delimit it from parameters.[...]", and also indicates that quotes are mandatory for win9x. Maybe that the help could be updated?Macronucleus
M
2

Do the $INSTDIR variable maps to a directory whose name contains spaces? If so, you should add simple quotes to include the double quotes into the Execargument :

Exec '"$INSTDIR\setup.exe"'
Macronucleus answered 5/6, 2012 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.