Solved

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

Posted on 2009-04-03
10
5,687 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

691 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