Jump to content
Sign in to follow this  

7Zip (command line) extract with progress bar

Recommended Posts


I have been trying to do this for last 3 days but nothing seems to be working (correctly). What i am trying to do is extracting an iso image to my pendrive during which progress bar should show the process. The actual size of the archive size is not known but no significant difference is there after extraction. Here is my code and where am i making mistke?

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
$Progress = GUICtrlCreateProgress(8, 56, 417, 25)
$Form = GUICreate("Copy File", 369, 128, 193, 126)
$Progress1 = GUICtrlCreateProgress(8, 56, 353, 17)
$close = GUICtrlCreateButton("Close", 200, 88, 75, 25, 0)
$start = GUICtrlCreateButton("Start", 80, 88, 75, 25, 0)
$Source = "E:\archive.iso"
$Dest = "K:\TEST\"
Const $INITIAL_SIZE = DriveSpaceFree( "K:" )
Const $FILE_SIZE = FileGetSize ( $Source )
While 1
  $msg = GUIGetMsg()
  Case $msg = $GUI_EVENT_CLOSE
  Case $msg = $close
  Case $msg = $start
   $Extract = Run(@ScriptDir & '\7z.exe' & ' x "' & $Source & '" ' & "-y -o" & '"' & $Dest & '"', "", @SW_HIDE)
   Sleep (100)
   While ProcessExists($Extract) > 0
    $SPACE_FREE = DriveSpaceFree( "K:" )
   $percentage = Round((( DriveSpaceFree( "K:" ) - $INITIAL_SIZE ) * 100 / $FILE_SIZE), 0)
   If $percentage > 0 And $percentage < 101 Then

Any help is appriciated.

Share this post

Link to post
Share on other sites

Any help please...

Share this post

Link to post
Share on other sites

Look in your Program Files folder where 7zip is installed. In there, you will find an executable called 7zG.exe. It is the same thing as 7z.exe except it displays a GUI progressbar.

#include <ByteMe.au3>

Share this post

Link to post
Share on other sites

Look in your Program Files folder where 7zip is installed. In there, you will find an executable called 7zG.exe. It is the same thing as 7z.exe except it displays a GUI progressbar.

Thanks for the reply. That worked but in a seperate window. However i am trying to integrate the progress bar with in my GUI.

Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Similar Content

    • Skeletor
      By Skeletor
      Hi All,
      I want to make my progress bar progress with the amount of File lines read. 
      How would I do this correctly. So far the code below can sometimes run in the middle of the progress bar and state completed.. and other times it can run into the 200%. 
      ;======================================================================== ProgressOn("TITLE", "ACTION") ;======================================================================== For $count = 1 To _FileCountLines($FileRead) Step 1 $string = FileReadLine($FileRead, $count) $value1 = $input[1] $value2 = $input[2] $value3 = $input[3] $value4 = $input[4] $TM = FileWrite("C:\temp\test.txt", $value1 & " " & $value2 & " " & $value3 & " " & $value4 & @CRLF) ProgressSet($count, $count & "%") Next ;======================================================================== ; PROGRESS BAR OFF ;======================================================================== ProgressSet(_FileCountLines($FileRead), "Completed!") Sleep(750) ProgressOff() ;========================================================================  
    • Kevin Finnegan
      By Kevin Finnegan
      Hi all,
      Long time lurker and now forum poster! I'm writing a relatively simple backup script for my firm that automates the copy, compression and organization of Leaver's data on one of our secured NAS systems. I personally found the best method to do this so far was to use 7zG.exe (GUI version of 7Zip which can use command-line too) and it functions quite well!
      I would like to retrieve more info on whether any warnings or errors happen in 7Zip during the backup, but I can't quite get my head around the syntax and switches for reading out, it seems any adjustment I make to the RunWait call's string seems to break the backup or give unexpected repercussions! Hopefully its something silly I'm doing as I don't code very often.
      Here is the working version:
      ; Compress the directories one by one in the zip using the listfile.... Local $iPID = RunWait(@ScriptDir & "\bin\7zG.exe a -mx" & $compressionQuality & " -v" & $compressSplitFileSize & " -wc:\temp " _ & $backupToLocation & "\" & $userDirectory & ".7z @bin\listfile.txt -x@bin\excludefile.txt", "", @SW_SHOWDEFAULT, $STDOUT_CHILD) Ultimately I would love to switch entirely to 7za.exe (standalone) so that I can read the progress percentage, current file being uploaded and any warnings or errors could be processed and output to the AutoIT script's GUI I've created rather than jumping in and out of two applications per se.
    • mond1106
      By mond1106
      Im new to autoit im exploring some function and I am interested with the progress bar.
      Is it possible to have a end user input in how much the bar will progress?
      I saw this code in the examples.
      Func Example()
          ; Display a progress bar window.
          ProgressOn("Progress Meter", "Increments every second", "0%")
          ; Update the progress value of the progress bar window every second.
          For $i = 10 To 100 Step 10
              ProgressSet($i, $i & "%")
          ; Set the "subtext" and "maintext" of the progress bar window.
          ProgressSet(100, "Done", "Complete")
          ; Close the progress window.
       EndFunc   ;==>Example
      Thank you.

    • j0kky
      By j0kky
      Hi guys,
      I often need zipping\unzipping function within my scripts, so I've decided to do a systematic research about it to understand which options I had. I'm sharing with you these results because I think it can save some time to somobody
      Autoit coders produced much material from 2005 till now, most of it consists of UDF wrappers of 3rd parts libraries, but there are some exception.
      Let's start:
      ZIP from scratch UDF: written by joakim. You can retrieve some info from a zip file, but it is just a PoC script, as I can see. LZ UDF: written by trancexx: another exception. It use native windows compression, so it doesn't need anything. It can work with memory, it doesn't work with files. LZMA UDF: written by Ward. He writes a dll which can be directly included or can be embedded within an au3 file. It can work with memory, it doesn't work with files. [it needs LZMA.dll or LZMA.dll.au3](link missing) Package UDF: written by Yashied. It is useful for dealing with package (.pkr) file. ZIP UDF: written by Wraithdu (yet torels UDF): the exception! Based on zipfldr.dll, a native library of Windows, so it does not need to include an external library into the script. It is its strenght, but its weak point too: if zipfldr.dll is corrupted or is missing, your script will not do what you expect. gZip UDF: written by Zinthose. Based on the parsing of gZip.exe output. It can work with memory, it doesn't work with files. [it needs gZip.exe] ZLib UDF: written by monoceres. Based on ZLib.dll. It can compress\uncompress data in memory, it doesn't work with files. [it needs ZLib.dll] pZip UDF: written by asdf8. Based on ZLib.dll. It can extract\add\overwrite file into archives. [it needs pZip.dll] ZLib and gZip UDF: written by Ward. Based on ZLib.dll but it does not need the dll file, because it is written directly in the UDF! It can compress\uncompress data in memory, and it can work with files. It works with gZip format too. (link missing) XZip UDF: written by eltorro, KXM and erifash. Based on XZip.dll, a COM dll. [it needs XZip.dll] XZip UDF: written by mLipok. Based on XZip.dll, a COM dll. A more complete alternative to previous UDF. [it needs XZip.dll] unRAR UDF: written by rasim. Based on unRAR.dll. You can just uncompress rar files with this one (the only method for new v5 RAR files). [it needs unRAR.dll] Parsing unRAR.exe output: you can just uncompress rar files in this way (the only method for new v5 RAR files). [it needs unRAR.exe] 7Zip: I spent a lot of time with it, because I think it is the most useful, there are different approaches: Parsing 7za.exe output, it is the simplest (and in my opinion the best) way, some UDFs can help with it, as jennico UDF (thanks to Screen Scrape script by Valik, it seems it doesn't work in Windows 10) [it needs 7za.exe] Using 3rd part dll, as rasim UDF (yet jak UDF). He rewrites a dll which can be simply invoked by his UDF [it needs 7-zip32.dll and\or 7-zip64.dll]. With Decipher UDF you doesn't need to include the dll in your project, because it is compiled into the script and loaded in memory directly at runtime. Invoking 7za.dll. This is the most complicated approach because the library doesn't use standard COM interfaces. Anyway dany, Starg, milky, trancexx, Mugen and finally Biatu had spent some time with it and they reach a sort of partial result. [it needs 7za.dll]  
      Comment here to add suggestions\links\UDF I forgot and I'll update this post with them!
    • Skysnake
      By Skysnake
      Perhaps someone would benefit off this.  I made heavy use of the Help file example.
      Only question I have here, is is there a better way to do the Regex for finding "error|ERROR|Error" in the source string?  Thx
      Example7zPwd() Func Example7zPwd() ;-- Local $iPID = Run(@ComSpec & " /c DIR Example.au3", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $iPID = Run(@ComSpec & " /c 7za t -pmasale myzip.zip ", "c:\files\testing", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $sOutput = "" Local $myError = 0 ConsoleWrite("$myError:" & $myError & @CRLF) While 1 $sOutput = StdoutRead($iPID) If @error Then ; Exit the loop if the process closes or StdoutRead returns an error. ExitLoop EndIf MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput, 5) If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then $myError = $myError + 1 ;ConsoleWrite("$sOutput: " & $sOutput & @CRLF) ConsoleWrite("$myError: " & $myError & @CRLF) WEnd While 1 $sOutput = StderrRead($iPID) If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop EndIf MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput, 15) WEnd ConsoleWrite("$myError: " & $myError & @CRLF) If $myError > 0 Then MsgBox(64, "An Error Occurred", "The upgrade may be incomplete. An error occurred") EndIf If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then Is the Regex here optimized?