Search code examples
nsis

NSISdl could not open file during download


I'm using NSIS to create an installer which will install files from a web server. I'm using the NSISdl plugin to download the files but they are not downloading, it just says Download Failed: failed to open file.

This is the section which is doing the download, could I be missed something here.

 Section "Aquiva"
    ; Set    output path to the installation directory.
    SetOutPath $INSTDIR

    ;Include files from this location, and copy that to the current
    ;out path

    NSISdl::download http://41.78.239.158/Aquiva.exe
Pop $R0 ;Get the return value
  StrCmp $R0 "success" +3
    MessageBox MB_OK "Download failed: $R0"
    Quit

SectionEnd ; end the section

Solution

  • You should use inetc for this purpose:

    inetc::get "http://41.78.239.158/Aquiva.exe" "$EXEDIR\Aquiva.exe"
    pop $R0
    DetailPrint "Result: $R0"
    

    You can get it here

    If you insist on using NSISdl, your problem is probably due to not specifying the destination file, try this:

    NSISdl::download http://41.78.239.158/Aquiva.exe "$INSTDIR\Aquiva.exe"
    pop $R0
    ...