15

I'm using the following NSIS script:

Name "My app wrapper"
Outfile "MyAppSetup.exe"
InstallDir $TEMP\MyApp\Install
Function .onInit
SetSilent silent
FunctionEnd
Section ""
    SetOutPath $TEMP\MyApp\Install
    File installer.msi
    File setup.exe
    Exec setup.exe
SectionEnd

The intention is that the installer will wrap up those two files, installer.msi and setup.exe (which is a bootstrapper to install prereqs and then call installer.msi) into the MyApp Setup.exe file. When MyAppSetup.exe is run, it should extract installer.msi and setup.exe to the $Temp\MyApp\Install directory, and it should run setup.exe from that directory.

However, when I run MyAppSetup from the desktop, it executes a setup.exe file that it finds on the desktop, and I don't even see a MyApp\Install directory in C:\Temp.

What do I need to do to get this script to install the files to the right location and to execute the right file?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Mike Pateras
  • 14,715
  • 30
  • 97
  • 137

3 Answers3

17
Section
InitPluginsDir
SetOutPath "$pluginsdir\MyApp\Install" ;It is better to put stuff in $pluginsdir, $temp is shared

File installer.msi
File setup.exe

ExecWait '"$pluginsdir\MyApp\Install\setup.exe"' ;You should always use full paths and proper quotes

SetOutPath $exedir ;Change current dir so $temp and $pluginsdir is not locked by our open handle
SectionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
5

I don't know if it would solve your problem but I would write :

Exec $TEMP\MyApp\Instal\setup.exe

Are you sure that $TEMP is pointing to C:/Temp? Did you check it?

F-A
  • 643
  • 3
  • 10
  • Ah, you're right. It's pointing to something in AppData. I see the files there, now. It was putting the files in the correct location. I think the full path was the solution, as well. It's something I had tried before, but I think for some reason I wasn't getting the latest version of the installer. – Mike Pateras Feb 25 '11 at 17:59
3

This is another way to do it

Function .onInit

    InitPluginsDir
        File /oname=$PLUGINSDIR\test.exe "test.exe"

FunctionEnd

Section "Exec file" SecFile

    nsExec::Exec $PLUGINSDIR\test.exe

SectionEnd
Yuri Korolov
  • 500
  • 2
  • 6