问题
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
回答1:
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)
回答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 Exec
argument :
Exec '"$INSTDIR\setup.exe"'
来源:https://stackoverflow.com/questions/10897271/exec-not-working-in-nsis-installer