Jump to content

Recommended Posts

Posted

The 7zip help file lists 6 exit codes for 7z.exe. What I am trying to do is get the code to check if the extraction completed successfully or erred.

I have tried to use the the STDOUT and STDERR streams and also the merged stream but I don't get any of the return codes listed. I only get a blank string. Is it possible to get the code this way?

Thanks

Local $Runstring = 7z.exe x "Z:\Utils\Office\Hotfixes\KB907417.exe" -aoa -o"C:\DOCUME~1\Benners\LOCALS~1\Temp\KB907417 *.msp -y
Local $Run = Run($Runstring, '', @SW_HIDE, 8)
Local $iReturnCode = 9 ; set to check if changed

While ProcessExists($Run) ; Loop while the exe is running.
    $iReturnCode = StdoutRead($run) ; also used StderrRead
    Sleep(10)
WEnd

MsgBox(0,'return', $iReturnCode)
Posted (edited)

Why don't you simply use RunWait. Or do you need to read something with StdoutRead?

if want to use Run then take a look here

BTW: if this a microsoft hotfix, it should have an switch to extract itself.

Edited by JFX
Posted

Your code was a bit complicated, so I simplified it. Below, I tested it and if it extracted fine, it returned zero. If the file already existed, it returned 2.

#include <Constants.au3>
$iReturnCode = RunWait("7z.exe e test.zip", @ScriptDir, "", $STDERR_CHILD + $STDOUT_CHILD)
MsgBox(0,'return', $iReturnCode)

#include <ByteMe.au3>

Posted

Thanks for the replies.

@JFX

I have some code inside the while loop that checks the size of the folder the exe is extracted to and it updates a progress bar with the result. I looked at the link you posted and tested it with a few errors and it works.

The reason for using 7zip is there are other files besides the office ones and I can use 7zip to only extract certain file types from the archive.

@sleepydvdr

Thanks for your code, I always try to whittle down to the minimum when I have working code. The reason is above why I don't use RunWait, I need to update a progress bar with some sort of progress and the way I found was to get the dir size during extraction.

Posted

hi,

Is there a reason why you don't want to use RunWait and 7zG.exe?

-smartee

7zG is the GUI version of 7zip. I already have a GUI for a program I am rewriting (Office Integrator) and there are progress bars that take returned values and update from them.

Cheers

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...