Here is what I'm trying to achieve: I want to call the installer passing as the first parameter, the EXE file I want to execute after the installation run successfully.
Like this:
c:\downloads\myinstall.exe "c:\Program Files (x86)\MyApp\Myapp.exe"
In the above case, I want to call Myapp.exe
after the installation finishes.
Is this possible?
First a word of warning: I do not feel well about letting your installer run an arbitrary command. It might get abused. An attacker might make user run your (possibly code-signed) innocent installer with some malicious code. It might even fool an antivirus. At least my solution runs the code without Administrator privileges. But even so...
Your proposed command line syntax conflicts with standard Inno Setup commandline syntax. What if user runs the installer e.g. with /LOG
commandline switch like:
c:\downloads\myinstall.exe /LOG=c:\downloads\myinstall.log
You better stick with the switch syntax. E.g. add your own /RUN
switch:
c:\downloads\myinstall.exe /RUN="c:\Program Files (x86)\MyApp\Myapp.exe"
Also it makes the implementation easier, as you can use {param}
"constant". And you can use that in Run
section easily:
[Run]
Filename: "{param:RUN}"; flags: skipifdoesntexist
If you need more control, you can of course keep using Pascal code in CurStepChanged
. To read the /RUN
switch, use:
ExpandConstant('{param:RUN}')
See also Is it possible to accept custom command line parameters with Inno Setup.