Archive: How can make NSIS to download and run a file without user intervention?


How can make NSIS to download and run a file without user intervention?
Hi there,

I am new to NSIS.

My installation would like to give the user a selection of available components and each component links to an installation from my website. When the selection is made, I would like NSIS to download the files and run them without any user intervention.

1) The checksum of these files should be verified at the end of the download against a checksum log from my website, such as a TXT file
2) These files need to be run at a certain order, not just FIFO style
3) These files should be stored in a temp directory by default so that they won't take up resource when the installation is finished
4) Before the actual download, the user can request to save these files to an user directory so that they can transfer them to another PC

Can someone be so kind to give me some pointers on how to get this done?

Thanks a lot!


Hi saxe,

I'm a noob too, but some hints are better than nothing, right?

1) I saw this earlier: http://nsis.sourceforge.net/MD5_plugin
You can create the md5 checksum of a file and compare it to your text files. Reading from files is very well described in the NSIS help. To compare you can use StrCmp.

2) If the order depends on the chosen components, you can create a hidden section (that always gets executed) behind the other sections and use

${If} ${SectionIsSelected} ${section_name}
...
${EndIf}

to egt some order. Requires logiclib.nsh

3) NSIS uses the temporary folder when I execute my installer, maybe it saves downloads to %temp% too? Did you check that? You can use a tool like FolderChangesView from NirSoft to do that. otherwise the constant $Temp may help.

4) You can use a custom pre-function to ask if the files should be saved right before the install page is opened. See chapter 4.5.3 Callbacks in NSIS help. Use a message box to ask the user if the files should be saved and if so let him choose a folder to save to.

Good luck :)

1) Use the md5 plugin to create the md5 hash, and use the inetc or other download plugin to download a (text)file with the correct md5 hash in it. (Or create a php script that sends the md5hash for a requested filename.)
2) Sections are executed in the order that they appear in your .nsi script.
3) $PLUGINSDIR is your friend.
4) Create a custom page with nsDialogs, that offers the user a choice between temp or selected folder. There's an excellent tutorial in the nsDialogs readme. http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html


Thanks for the reply.

How about pointers to how to download a file from website and execute it? If codes are too much to ask, please give me a few key words so that I can use them to search this website.

I want to create a simple one to see how it works first

Again, thanks


I know it's possible, but I don't know where it is written down. You could search this site http://nsis.sourceforge.net/List_of_...ring_Functions for web installtion or similar terms.


Thanks´╝î Seban

Hopefully some guru will show us the way


yw

it's a lot of searching, but most of the time the answer is somewhere to be found ;)


I tried, but I must be using the wrong keywords.


I guess I can use the codes like this:

NSISdl::download http://www.myweb.com/support/downloads/myapp.exe localfile.exe
Pop $R0 ;Get the return value
StrCmp $R0 "success" +3
MessageBox MB_OK "Download failed: $R0"
Quit

exec localfile.exe


just stumbled upon this thread: http://forums.winamp.com/showthread.php?t=332999

maybe you can need this (didn't check it out though)