Winamp & SHOUTcast Forums How to extract a .rar file and copy it to a diff. folder??

 11th November 2005, 18:26 #1 cirerita Junior Member   Join Date: Oct 2005 Posts: 25 How to extract a .rar file and copy it to a diff. folder?? Hi, I made a search and found that the nsExec command apparently can be used to extract .rar files together with Unrar, or so I understood. I've been trying to use it in my installer to no avail. Mind you, I'm a 99% newbie, so that's normal, I guess. Here's the basic script: SetOutPath "$INSTDIR" File "..\MediaAutoGraph.rar" nsExec::unrar '"$INSTDIR\MediaAutoGraph.rar"' I've been switching the " here and there, but I always get some sort of error. I just want to extract the .rar file (it will create a folder with a lot of files) and then I want to copy the extracted folder to a different location and overwrite an existing one. any idea? thanks a lot...
 11th November 2005, 18:31 #2 kichik M.I.A.[NSIS Dev, Mod]     Join Date: Oct 2001 Location: Israel Posts: 11,343 nsExec can be used to run unrar.exe. It can't extract files from RAR archives on its own. Extract unrar.exe along with the RAR archive and use something like:code:nsExec::ExecToLog '"C:\path\to\unrar.exe" "$INSTDIR\MediaAutoGraph.rar"'unrar.exe might require some more information on the command line, so this example will probably not work as is. NSIS FAQ | NSIS Home Page | Donate$ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius
 11th November 2005, 18:37 #3 cirerita Junior Member   Join Date: Oct 2005 Posts: 25 Is there any other way to extract files on the fly from a rar archive?
 11th November 2005, 18:43 #4 kichik M.I.A.[NSIS Dev, Mod]     Join Date: Oct 2001 Location: Israel Posts: 11,343 7-zip's command line utility might be able to extract RAR archives as well. NSIS FAQ | NSIS Home Page | Donate $"I hear and I forget. I see and I remember. I do and I understand." -- Confucius  11th November 2005, 18:50 #5 cirerita Junior Member Join Date: Oct 2005 Posts: 25 Ok, I tried your command line and extracting also UnRAR.exe together with the rar archive. Obviously, UnRAR needs some extra parameters to extract the archive. This is what i get in the log window: Extract: UnRAR.exe... 100% Extract: MediaAutoGraph.rar... 100% UNRAR 3.51 freeware Copyright (c) 1993-2005 Alexander Roshal Usage: unrar - - <@listfiles...> e Extract files to current directory l[t,b] List archive [technical, bare] p Print file to stdout t Test archive files v[t,b] Verbosely list archive [technical,bare] x Extract files with full path - Stop switches scanning ac Clear Archive attribute after compression or extraction ad Append archive name to destination path ap Set path inside archive av- Disable authenticity verification check c- Disable comments show cfg- Disable read configuration cl Convert names to lower case cu Convert names to upper case dh Open shared files ep Exclude paths from names ep3 Expand paths to full including the drive letter f Freshen files id[c,d,p,q] Disable messages ierr Send all messages to stderr inul Disable all messages ioff Turn PC off after completing an operation kb Keep broken extracted files n Include only specified file n@ Read file names to include from stdin n@ Include files in specified list file o+ Overwrite existing files o- Do not overwrite existing files oc Set NTFS Compressed attribute ow Save or restore file owner and group p[password] Set password p- Do not query password r Recurse subdirectories ri [:] Set priority (0-default,1-min..15-max) and sleep time in ms ta Process files modified after in YYYYMMDDHHMMSS format tb Process files modified before in YYYYMMDDHHMMSS format tn  11th November 2005, 19:24 #6 cirerita Junior Member Join Date: Oct 2005 Posts: 25 I tried this, but no luck: File "..\UnRAR.exe" File "..\MediaAutoGraph.rar" nsExec::ExecToLog '"$INSTDIR\UnRAR.exe e" "MediaAutoGraph.rar"' also tried using 7z: File "..\7z.exe" File "..\MediaAutoGraph.rar" nsExec::ExecToLog '"$INSTDIR\7z.exe e" "MediaAutoGraph.rar"'  11th November 2005, 19:25 #7 kichik M.I.A.[NSIS Dev, Mod] Join Date: Oct 2001 Location: Israel Posts: 11,343 Get the 'e' out of the quotes. The first quotes should surround just the path to the executable. NSIS FAQ | NSIS Home Page | Donate$ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius
 11th November 2005, 19:26 #8 Comm@nder21 Major Dude   Join Date: Jul 2003 Location: germany, b-w Posts: 734 code: also tried using 7z: File "..\7z.exe" File "..\MediaAutoGraph.rar" nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar' hand by comm@nder21 ---------- WiKi pages:CreateInternetShortcut|Enhanced FindWindow|Parse CSV-Data|Open/Close CD-Drive|Installer without Icon|Vista application compatibility  11th November 2005, 19:40 #9 cirerita Junior Member Join Date: Oct 2005 Posts: 25 thanks guys, got it working: nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar -oc:\downloads\test"' it copies the content of the rar archive to the downloads\test folder.
 12th November 2005, 08:25 #10 Afrow UK Moderator     Join Date: Nov 2002 Location: Surrey, England Posts: 8,434 I think you've got one to many quotes there. nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar -o"c:\downloads\test"' -Stu  12th November 2005, 08:35 #11 cirerita Junior Member Join Date: Oct 2005 Posts: 25 it'w weird, beucause it does work this way: nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar -aoa -oc:\downloads\test"' [aoa command overwrites without asking first] i'll try your way now... well, well, well, it works both ways. nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar -aoa -oc:\downloads\test"' and nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar -aoa -o"c:\downloads\test"' it seems that the right way should be the second one, but the first one also works. weird, huh?
 24th November 2006, 15:22 #12 AlexV Junior Member   Join Date: Nov 2006 Posts: 1 It's probably worth pointing out at this point that 7z.exe will only work if 7zip is installed. If you just ship 7z.exe and the target system has not got 7zip installed, it won't be able to extract anything. There is a standalone .exe provided by 7zip called 7za.exe, but unfortunately that does not extract from rar files. I'm trying to be able to extract rar's, zip's and 7z's in my installer, and the only solution I have found so far is to ship both 7za.exe and unrar.exe, for a whopping total of 686k. If anyone knows of a more lightweight solution with zip, 7z, and rar capability, I'd love to hear of it.
 24th November 2006, 16:08 #13 vitoco Junior Member   Join Date: May 2006 Posts: 22 BTW, why to use NSIS to extract a temporary archive file like a RAR or ZIP (and it's uncompressor utility) and then extract final files from the archive? NSIS can drop final files just like an archiver. You only need to uncompress your files locally and add them (or the directory containing them) to your NSI script, then compile. File /r and it's other options are enougth. I can't think about a situation where a simple archiver is required as an intermediate step. At least for me, NSIS's solid lzma compress a lot more than WinRAR with the maximum compression option. ++Vitoco
22nd April 2011, 01:36   #14
erundil
Junior Member

Join Date: Apr 2011
Posts: 20
Quote:
 Originally Posted by vitoco BTW, why to use NSIS to extract a temporary archive file like a RAR or ZIP (and it's uncompressor utility) and then extract final files from the archive?
We dont speak of something like this:
File archive.rar
Unpack archive.rar

We speak about using installer to unpack an archive which already exists (on same CD maybe).
What is more - NSIS have it's limitations - it's 2GB per file. If you want to distribute some more, u need to pack data into separate archives.

 22nd April 2011, 05:20 #15 MSG Major Dude   Join Date: Oct 2006 Posts: 1,892 Please don't reply to a discussion that's been closed for five(!) years.
 Winamp & SHOUTcast Forums How to extract a .rar file and copy it to a diff. folder??