Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I make a SFX archive with winrar via CMD?

Posted on 2009-04-03
10
Medium Priority
?
6,056 Views
Last Modified: 2013-12-01
I'm trying to make a SFX archive in winrar via the command line. I read the winrar manual, but I am completely lost.

I want to create a SFX that:
-Extracts the contents to: C:\WINDOWS\System32
-Advanced>SFX Options>Modes>Silent Mode>Hide All
-Overwrites the files

I don't care about the other settings.

Thanks,
Alex
0
Comment
Question by:Deathader
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 

Author Comment

by:Deathader
ID: 24062131
I have tried putting the following code in a batch file. It makes the files, but you can see the dialog and it doesn't run anything on completion. If anyone can help that would be great.
"C:\Program Files\WinRAR\RAR.exe"  a -sfx  -d"C:\WINDOWS\System32" -s1 -esh -idq -inul -o+ -m5 -mt2 -r -s -t  "output.exe"  @"files_to_include.txt"
pause

Open in new window

0
 
LVL 3

Expert Comment

by:avdej
ID: 24062267
Hi, Alex!

Basicaly, for your particular need, you have to execute the following line:
rar a -o+ -rr -t -ep -sfx <SFX_name> @<filelist>

where
<SFX_name> should be replaced with the target archive name (without .exe extention)
AND
<filelist> should be replaced with a path of a text file with files to add (one per line)
OR
@<filelist> should be replaced with a space separated files listed directly here (i.e. without using an outer text file).

But to ensure that it will really work I suggest you do the following:
*. Copy the attached code snippet into a .cmd file
*. Place the file into directory your SFX archive should be created in.
*. Change the entries in first THREE lines after =...
    with
   1) full path of WinRar directory (not WinRar.exe!)
   2) name of the target SFX archive (without .exe)
   3) full path of a text file with full paths of files to archive
*. Execute the .cmd file from that directory
*. Your SFX file will be created here as well.
*. Here you are!


Example content for filelist.exe:
C:\Temp\file1
C:\Temp\DirA\file2
C:\Temp\DirB\file3
...

NOTE: Unfortunately it seems to be not possible to set the advanced SFX options you mentioned above in the command line version of the WinRar utility. Thus your user will still have to manually navigate to C:\WINDOWS\system32 and to manually confirm any file overwriting.



set winrar=C:\Program Files\WinRAR
set sfx=MyArchive
set files=C:\Temp\filelist.txt
 
set winrar="%winrar%\rar"
 
%winrar% a -o+ -rr -t -ep -sfx %sfx% @%files%
 
pause

Open in new window

0
 

Author Comment

by:Deathader
ID: 24062346
Is it possible to do what i'm looking for with another archiver, maybe 7zip?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Deathader
ID: 24063072
I've known about iexpress. I was using it originally, but I write 50 - 60 SFX installers / day, and it was taking forever to make them. So I wrote a vb.net program that you plug the file names into and it writes a batch file. If there is a way to run iexpress via command line, that would be great :)
0
 
LVL 3

Expert Comment

by:avdej
ID: 24063786
Yes, there is. But you will have to
1. create/have a .SED file (a kind of .INF file for IExpress) for the target archive. Run an initial single pass with IExpress GUI to include all the files into it and to set the desired (quiet) options . [Of course, once you know/see the proper format for the manually created .SED file, you can generate such a file from BATCH or VB too. Open it in text editor and look what's inside].

2. THEN run IExpress with the following options:
iexpress /N /Q archive.SED

where archive.SED is the .SED file you want to provide.

The target archive will be created according to 'TargetName=' value set within .SED file.

A CS proverb says: Programmable is anything what is computable.

As you can see, your particular task is computable, so it IS programmable.

I wish you a lot of success!
Best regards,
Avdej



0
 

Author Comment

by:Deathader
ID: 24064201
I tried your /n /q command and it didn't work. I removed the /q switch, and ran it, and got this error:

Error Opening IExpress Self Extraction Directive File.

0
 
LVL 3

Accepted Solution

by:
avdej earned 1000 total points
ID: 24064333
It works rather perfectly.
Look at the Error message!

> Error Opening IExpress Self Extraction Directive File

'S'elf 'E'xtraction 'D'irective File IS the the .SED file I've mentioned above. Did you provided IT as the third argument? Please read my previous comment/instructions carefully.
0
 

Author Comment

by:Deathader
ID: 24064483
Fixed it :) I forgot to CD to the dir with the .SED file in it. I tried doing

iexpress /N /Q C:\Documents and Settings\Alex\Desktop\project1.SED

and

iexpress /N /Q "C:\Documents and Settings\Alex\Desktop\project1.SED"

but neither worked. When I cd' to the directory that the SED file was in, it worked perfectly :D

Thank you very much :)

0
 

Expert Comment

by:ansa45
ID: 25103122
Using rar this way and use the -s1 and -o+ BEFORE or AFTER the -sfx command doesn't really help in suppressing the dialog box or overwriting files.  If you just execute the output.exe from a command line, the silent and overwrite parameters don't kick in and you're still presented with dialog boxes.  Of course though, if you double click the output.exe in Windows explorer, you'll see nothing (just output.exe in your task manager).  So my question would be:  executing output.exe from a cmd line - how do you get it to extract silently and overwrite if files are already there (where you're extracting to).


<path to rar>\RAR.exe"  a -sfx  -d"C:\WINDOWS\System32" -s1 -esh -idq -inul -o+ -m5 -mt2 -r -s -t  "output.exe"  @"files_to_include.txt"
pause
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
I originally wrote this article to compare SARDU and YUMI, but have now added Easy2Boot, since that is the one I currently use and find the easiest to create and alter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question