Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 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...
cirerita is offline   Reply With Quote
Old 11th November 2005, 18:31   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,342
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
kichik is offline   Reply With Quote
Old 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?
cirerita is offline   Reply With Quote
Old 11th November 2005, 18:43   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,342
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
kichik is offline   Reply With Quote
Old 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 <command> -<switch 1> -<switch N> <archive> <files...>
<@listfiles...> <path_to_extract\>

<Commands>
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

<Switches>
- Stop switches scanning
ac Clear Archive attribute after compression or extraction
ad Append archive name to destination path
ap<path> 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<file> Include only specified file
n@ Read file names to include from stdin
n@<list> 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<P>[:<S>] Set priority (0-default,1-min..15-max) and sleep time in ms
ta<date> Process files modified after <date> in YYYYMMDDHHMMSS format
tb<date> Process files modified before <date> in YYYYMMDDHHMMSS format
tn<time> Process files newer than <time>
to<time> Process files older than <time>
ts<m,c,a>[N] Save or restore file time (modification, creation, access)
u Update files
v List all volumes
ver[n] File version control
vp Pause before each volume
x<file> Exclude specified file
x@ Read file names to exclude from stdin
x@<list> Exclude files in specified list file
y Assume Yes on all queries
cirerita is offline   Reply With Quote
Old 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"'
cirerita is offline   Reply With Quote
Old 11th November 2005, 19:25   #7
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,342
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
kichik is offline   Reply With Quote
Old 11th November 2005, 19:26   #8
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
code:


also tried using 7z:
File "..\7z.exe"
File "..\MediaAutoGraph.rar"
nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar'
Comm@nder21 is offline   Reply With Quote
Old 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.
cirerita is offline   Reply With Quote
Old 12th November 2005, 08:25   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,302
I think you've got one to many quotes there.
nsExec::ExecToLog '"$INSTDIR\7z.exe" e MediaAutoGraph.rar -o"c:\downloads\test"'

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 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?
cirerita is offline   Reply With Quote
Old 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.
AlexV is offline   Reply With Quote
Old 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
vitoco is offline   Reply With Quote
Old 22nd April 2011, 01:36   #14
erundil
Junior Member
 
Join Date: Apr 2011
Posts: 17
Quote:
Originally Posted by vitoco View Post
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.
erundil is offline   Reply With Quote
Old 22nd April 2011, 05:20   #15
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,894
Please don't reply to a discussion that's been closed for five(!) years.
MSG is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump