|
|
#1 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Hello,
I just started using NSIS about two days ago. I'm trying to create an installer (pretty much empty) that copies files from a dvd disc to the destination computer. CopyFiles works for the copying part, but it doesn't work for the detail screen during installation. My question is pretty simple: [1]How do I copy all the files (161) and folders (38), [2]make it print every copied item (file or folder) and [3]update the status bar while copying? [1] I'm using CopyFiles /SILENT "$EXEDIR\installer_files\*.*" "$INSTDIR" 2312474. All files are located in a dir (called installer_files), which is located in the installer.exe dir. The integer is the complete size of the files. [2] I'm using RecFind.nsh for this, but it seems to be searching backwards (Z to A)... [3] RecFind seems to do some updating, but not the way I want it: I'd like to see the bar reach the end when the last file is copied. I read this topic, but I had trouble following the conversation: http://forums.winamp.com/showthread....ight=copyfiles Any help is welcome, thanks in advance. edit: This is what I have so far: code: Last edited by mldebondt; 19th August 2006 at 12:45. |
|
|
|
|
|
#2 | |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Quote:
Another alternative you might consider is to use the Locate header included with NSIS. You can seach for files/folders and use a callback function to do the copy. In addtion, you can combine this with the NxS banner plugin to allow you to display a progress bar during the copy progress. (The first link above has examples of how you can do this.) |
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Thank you for your reaction, Comperio.
Right now, my first section looks like the example given at E.1.2, (Example (Locate with banner - NxS plugin required)) including the function LocateCallBack. Before the copying I recreate the dir structure (Example (Recreate directory structure)). At installation it pops up a window with progress, but it just hangs at about 2/3 of the way (it just jumps there it doesn't move anymore...). Is it necessary for the window to pop up? Situation now: Directory structure is recreated. Window (nxs) pops up when I copy the files. Status bar jumps to 2/3 and just waits there. All files are copied to $INSTDIR in stead of $INSTDIR\original_dir. The instfiles page of the installer doesn't show any copy info (DetailPrint should do this, right? But it doesn't) |
|
|
|
|
|
#4 | |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Quote:
And yes, you are correct about DetailPrint--it should update the progress bar. Just make sure you place those commands in the callback function you use for Locate. And you don't have to use the banner (nxs). The reason for doing so is that the progress bar is based on the total number of commands in all sections. Because you are looping and becuase you probably have to do more than just copy files, the progress bar itself probably won't indicate the correct "progress" when copying files. (Another thought: You might check out Afrow's RealProgress plugin too.) edit: You can recreate the directory structure on the fly by checking the value of $R8 in the locate callback function. Just call CreateDirectory '$R8' for each file. |
|
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
I copied the example from E.1.2 and it indeed says to jump to 78 of the way in the Update function. I've set the max to 161, but how can I add 1 (to /pos) each time it updates?
About the DetailPrint, that the list it creates when performing an action, right? So it adds a line to the Details list. But in my case it doesn't show anything, it just says So it skips all the file copying and dir creating stuff...code: Isn't it possble to use only the RealProgress plugin? I can use ${Locate} to create folders, copy files, update the RealProgress plugin and add lines to the Detail screen, right? If I use $R8 to create a dir, it tries to recreate the original dir ($R8 holds F:\original\dir and I just need the 'dir' part) |
|
|
|
|
|
#6 | |||
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Quote:
Example, let's say you set a variable called COUNTER as your file counter. Then, in the callback function, you'd do something like this: code: Quote:
Quote:
example (assuming the variable PERCENT is used for calculating the percentage of the bar): code: |
|||
|
|
|
|
|
#7 | |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Quote:
Thanks for the mathmatical stuff (should've read the entire manual before asking this... ). So here's where I am now: For some reason it calls LocateCallBack, jumps straight on to abortcheck and stop locating... Without any copying being done...code: |
|
|
|
|
|
|
#8 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
You probably don't need that first LOCATE call--you can do it all on one step using the 2nd locate call. And since you are using the RealProgress plugin, you probably don't need the /B=1 (for the banner).
I also discovered that you have to call SetDetailsPrint to "both" in order to get the details to change. (Not sure if this is a function of NSIS or ${Locate}--never got that far.) It also occured to me that you may want to check for errors during the copy to let the user know there was something wrong. I introduced another variable called "ErrorFlag" that gets set to -1 if there were errors (0 otheriwse). Take a look at the attached code--it should be easy to follow. |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Thansk a lot for taking so much time to help me! Really appreciate it.
I replaced my code with yours. The DetailPrint works now and the installer also copies all files. Only it doesn't create all dirs, just the ones that are about 5 levels deep. The weirdness lies in the CopyFiles line. When I use CopyFiles /SILENT "$EXEDIR\installer_files" "$INSTDIR" to copy the files, it copies just the installer_files directory including its contents. And when I use CopyFiles /SILENT "$R9" "$INSTDIR" it copies as mentioned above...code: Also the progress bar doesn't advance any sooner than 100%. $Percent stays 0 until it reaches 161 files. |
|
|
|
|
|
#10 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Sorry, I was so caught up in helping with the progress bar, I didn't look at the rest of the code!
I think I see the problem with the CopyFiles code, but I'll have to think about a good solution. The issue here is that the CopyFiles command should be copying from "$R9" to $INSTDIR\[path your files]. But here's the issue: Due to the way the locate plugin deals with the stack, you usually can't call any functions in the callback fucntion that might manuiplate the stack or you can run into problems. I'll give it some thought and will post it once I've figured it out. As far as why the progress bar fails to update, I'm not sure. I'll look into this too. (perhaps you can PM AfrowUK to see if he's got any ideas since the RealProgress plugin is his baby.) |
|
|
|
|
|
#11 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Ok, try the attached function. You'll also need to add this to the top of your script:
code: |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Thank you very much for finding a possible sollution, but this morning I found my own.
Snippet from LocateCallBack: I used a lot of MessageBox' to find it, but here it is. It's probably the worst possible sollution, but it works: It creates all dirs (I used a bit of code from the Recreate example) and copies the files correct.code: I want to thank you very much for helping me with this issue! ![]() The status bar still doesn't progress correctly (btw: Including the dirs to be created, there are 199 items which increment the $Counter). So I decided to make it move every two items: This works. It's not really correct, since some files are over 200MB and others are just 4b.code: So, thank you very, very much for all your help and time. Couldn't have done it without you!! Now, there are some other issues with my installer and I was wondering if you could help me with this too or should I make another topic for these: [1]I found it pretty hard to place a brandingimage for the installer. I actually had to create a custom page with a creator function to place the image. Now I want to do the same thing for the uninstaller, but I can't get it to work. [2]The brandingimage is read from a dir called installer, but I want it inside the installer so that dir can be deleted an I only need the installer. |
|
|
|
|
|
#13 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Usually, it's best to put new items under new threads. (It just makes it easier for others to search and find the topics later.) But since you asked, I'll take a stab:
1) Create custom pages in the uninstall the same way as an install. Except use UninstPage instead of Page and prefix your uninstall function page functions with "un." to let the compiler know to add these to the uninstall. (Refer to the help manuals and examples for more info.) 2) You can place your images in the PLUGSINDIR to ensure they get delted when you are done with them. (You'll proabably want to edit the page's INI file on the fly to add the full path of the image into the proper field. Use WriteIniStr and the text would be "$PLUGINSDIR\imagefilename.bmp.) |
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Thanks again, works perfectly (except for the uninstaller).
So the code I now have: code: Code I'm using for the installer (It's located before the license page): Code for the uninstaller I have (This one is before uninstConfirm):code: But the brandingimage for the uninstaller won't work. The line AddBrandingImage left 90 2 works for both uninstaller and installer, correct?code: |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Aug 2006
Location: Netherlands, The
Posts: 8
|
Hmm, it seems that .onInit only works for the installer. For the uninstaller I have to use un.onInit. So my .onInit and un.onInit now contain the same lines and it works!
Well, I guess my application is complete than... I'd like to thank you, Comperio, very very much for all your help and time spent on helping me! You're the best! |
|
|
|
|
|
#16 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
Glad I could be of help.
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|