benners Posted June 24, 2011 Posted June 24, 2011 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)
JFX Posted June 24, 2011 Posted June 24, 2011 (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 June 24, 2011 by JFX
sleepydvdr Posted June 24, 2011 Posted June 24, 2011 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>
benners Posted June 24, 2011 Author Posted June 24, 2011 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.
smartee Posted June 24, 2011 Posted June 24, 2011 hi, Is there a reason why you don't want to use RunWait and 7zG.exe? -smartee
benners Posted June 24, 2011 Author Posted June 24, 2011 hi,Is there a reason why you don't want to use RunWait and 7zG.exe?-smartee7zG 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now