1

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)?

1
  • Both sections and function contain code (and plugin calls), only installer attributes are specified outside sections/functions...
    – Anders
    Dec 19, 2011 at 11:38

1 Answer 1

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.