How to run exe files in NSIS Script?
Asked Answered
M

2

15

In InnoSetup, there is a part called run which will execute the exe, batch file and msi. We can also give command line parameters to this run.

I provide the Innosetup sample:

[Run]
Filename: "{app}\msdirent.exe ";
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\NETCFSetupv2.msi""" ; Check:ShouldInstallComCtlUpdate ;

But in NSISS Script, how to run my exe and also I have to provide command line arguments to the concerned exe?

Maller answered 2/1, 2012 at 12:0 Comment(0)
B
14

Try the following commands

Exec "$APPS\msdirent.exe"

For Command Line Args,

Exec "$APPS\msdirent.exe 1"

For Adding msdirent.exe to the installer,

SetOutPath "$APPS"
File "localpath\msdirent.exe"

Exec "$APPS\msdirent.exe 1"
Boycie answered 2/1, 2012 at 12:19 Comment(3)
@ Sivakg: How to pack that msdirent.exe into the installer?Maller
You need to quote these paths correctly, see the NSIS manual or my answer for examples!Trochanter
@Sivakg: How to pack that msdirent.exe into the uninstaller?Phalanger
T
27

You have 3 NSIS instructions that can start a new process: Exec, ExecWait and ExecShell (Internally the first two use CreateProcess and the last one uses ShellExecute)

In all cases SetOutPath sets the working directory for the child process.

It is important to get the quoting correct since NSIS has 3 quote characters and windows paths with spaces should be quoted with ":

ExecWait '"$instdir\myapp.exe"'
Exec '"$instdir\otherapp.exe" param1 "par am 2" param3'
Trochanter answered 2/1, 2012 at 13:53 Comment(2)
@ Anders: Thanks for your answer. I upvote your answer but Sivakg is the one who give the answer first.Maller
@Maller Well, his current answer is wrong, those Exec's will not work on all systems...Trochanter
B
14

Try the following commands

Exec "$APPS\msdirent.exe"

For Command Line Args,

Exec "$APPS\msdirent.exe 1"

For Adding msdirent.exe to the installer,

SetOutPath "$APPS"
File "localpath\msdirent.exe"

Exec "$APPS\msdirent.exe 1"
Boycie answered 2/1, 2012 at 12:19 Comment(3)
@ Sivakg: How to pack that msdirent.exe into the installer?Maller
You need to quote these paths correctly, see the NSIS manual or my answer for examples!Trochanter
@Sivakg: How to pack that msdirent.exe into the uninstaller?Phalanger

© 2022 - 2024 — McMap. All rights reserved.