开发者

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

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 do开发者_JAVA百科n'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?


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


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?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜