how to test for bad zip using wzunzip called from shell command in VB6

Posted on 2006-04-27
Last Modified: 2010-05-18
I have written a small program in vb6 which calls wzunzip in shell command to unzip file to specific location.  Everything runs fine as long as the zip is in tact.  I am trying to take into consideration if the zip file is bad, how to determine that before my process continues.

Does anyone know how to retrieve and decipher the return code after the shell command calling WZUNZIP to determine if it is a bad zip or not.  I prefer to use wzunzip and not have to change the compression tool mid stream. It has a switch (-t) to test the zip but I don't know what value it returns to decipher the results.

Any help is appreciated.
Question by:edfreels
    LVL 3

    Expert Comment

    Could you save the results in a .txt file and analyse that?


    DIR >log.txt

    This will store the results of the dir in the log.txt file
    LVL 1

    Author Comment

    I have tried pulling the results into a variable and displaying it on the screen to decipher.  The problem is the results are different for each file it tests and unzips.  The result it is returning is an integer.  For example, the first file I test returns 176 and then the value returned when unzipping the file is 1688.  Then the next file that I run the same commands on returns 2 completely different numbers.  Here is how I am running the process to test the zip file for validity from the shell command:

    ReturnValue = Shell(sBaseFolder & "wzunzip -t " & sUpldPath & strFile, vbMinimizedNoFocus)

    The -t switch is telling it to test the zip.  I then run the following Shell command to unzip the file:

    ReturnValue1 = Shell(sBaseFolder & "wzunzip -o " & sUpldPath & strFile & " " & sTempPath, vbMinimizedNoFocus)

    Is there a different way to retrieve the status or results or a way to decipher what these numbers mean?  Am I going about it the wrong way?
    LVL 3

    Accepted Solution

    I would try something like this

    ReturnValue = Shell(sBaseFolder & "wzunzip -t " & sUpldPath & strFile & ">log.txt", vbMinimizedNoFocus)

    then analyise the results stored in the log.txt file using VB to see if passed or failed

    if you open log.txt in notepad you can see what text you need to look for, ie if passed or failed.
    LVL 1

    Author Comment

    This is just what I needed.  I knew there had to be a way to get the results.  Thanks so much!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now