How can I get NSIS to install and execute files from a temp directory?
Asked Answered
C

3

16

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?

Culinary answered 25/2, 2011 at 16:4 Comment(0)
S
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?

Scalable answered 25/2, 2011 at 16:15 Comment(1)
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.Culinary
A
18
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
Allophane answered 25/2, 2011 at 16:18 Comment(1)
Whats the benefit of $pluginsdir over $temp? and what is $pluginsdir?Cicely
S
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?

Scalable answered 25/2, 2011 at 16:15 Comment(1)
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.Culinary
E
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
Epidiascope answered 3/11, 2012 at 0:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.