Run a DOS command line to examine RAR contents

C

Cooz

Hi everyone,

An application that I am trying to write (MyApp) should read the contents of
..rar archives and determine whether certain files are present. The harder
part of this job is actually done by UnRAR.exe
(http://www.rarlab.com/rar_add.htm), a free command line-tool that can
extract .rar-archives, and, set up with the right switches, can write the
contents of the archive to a .txt file.

Here is an example that does the trick:
D:\rarfile\unrar.exe lb -pabc D:\rarfile\xtpass.part01.rar >
D:\rarfile\raroutput.txt

"lb" stands for the "list basic" command which yields the bare filenames in
the archive.
"-p" provides the password. All archives that are to be examined have "abc"
as password.
" > ..." redirects the output to the specified file.

MyApp should, in my humble opinion, execute the following code to obtain the
..txt file (thePath refers to "D:\rarfile", psw to "abc", and rarFile for
example to "D:\rarfile\xtpass.part01.rar"):

Dim myProcess As New Process()
With myProcess
With .StartInfo
.FileName = thePath & "\unrar.exe"
.Arguments = "lb -p" & psw & " " & rarFile & " > " & _
thePath & "\raroutput.txt"
.CreateNoWindow = True
End With
.Start()
.WaitForExit()
.Dispose()
End With

However, this code does not create raroutput.txt. Why not? As a matter of
fact, when I type the above example in the Start menu's Run textbox, I won't
get my raroutput.txt either. But: when I type the example in a .bat file that
I save and subsequently double click, the correct raroutput.txt _is_ created.

I've tried to make MyApp write lines like the above example in a .bat file
and run this file, but this method slows down the application considerably;
it eventually even appears to hang.

What should I do to make MyApp produce the desired raroutput.txt? If the
run-the-.bat approach can be modified in such a way that it runs fast enough
and smoothly, that would do - but is this possible?

Thank you,
Cooz

I use VB 2005.
 
C

Cooz

Hi everyone,

Specifying "cmd" with StartInfo.Filename and preceding the
StartInfo.Arguments string by "/c " & thePath & "\unrar.exe " helps a lot.
Oh... those blind spots again...

Cooz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top