user2306856
user2306856

Reputation: 81

NSIS script: Embed an exe inside other exe and extract during installation

!include "MUI2.nsh"
!include "WordFunc.nsh"
 # define the name of the installer
outfile "simple installer.exe"


!macro installVddk

MessageBox MB_OKCANCEL "a.exe is required for installing agent.Do you wish to install it?" IDOK lblinst IDCANCEL abort_inst

abort_inst:
          ABORT
          GoTo lblinst


lblinst:
SetOutPath $EXEDir
;MessageBox MB_OK $OUTDIR
File a.exe
ExecWait "a.exe" $1
!macroend

# default section
section " Agent (required)" main_section
sectionEnd

Function .onInit
    !insertmacro installVddk 
FunctionEnd

My question is :

1.I have to keep the a.exe in the same directory as the NSI script during compilation. How and where do I specify the location from which the a.exe can be picked up, if it is a directory other than the NSI script?

2.If File a.exe command is extracting the exe , which code bundles the exe , during compilation .Please help

Upvotes: 1

Views: 2281

Answers (1)

slajma
slajma

Reputation: 1889

a.exe doesn't have to be in the same folder with your .nsi script when compiling, but you have to declare the full path in 'File' - consider the following:

    SetOutPath $EXEDir
    File "C:\A_folder\a.exe"
    ExecWait "$EXEDir\a.exe"
  1. with SetOutPath you tell where to deploy the file(s) when you run the installer
  2. then with File you tell NSIS which file(s) to wrap up (which will then be used during deployment ofc)

Upvotes: 2

Related Questions