Search code examples
downloadnsis

NSIS file downloader


I need NSIS script witch download file from the internet and execute it. I've read many examples but I still don't understand how to do it. For example

NSISdl::download http://www.domain.com/file localfile.exe 
    Pop $R0 ;Get the return value 
      StrCmp $R0 "success" +3 
      MessageBox MB_OK "Download Failed: $R0" 
      Quit

$R0 contains information about installation process ("cancel" or "success"). But I don't understand what the "localfile.exe" is? In what part of program I need write this code(section or function)?


Solution

  • localfile.exe is the path on the local system where you want to save the content you are downloading:

    !include LogicLib.nsh
    Section
    NSISdl::download "http://cdn.sstatic.net/stackoverflow/img/sprites.png" "$pluginsdir\image.png"
    Pop $0
    ${If} $0 == "success"
        ExecShell "" '"$pluginsdir\image.png"' ;Open image in default application
    ${Else}
        MessageBox mb_iconstop "Error: $0" ;Show cancel/error message
    ${EndIf}
    SectionEnd