PsaltyDS Posted June 20, 2006 Share Posted June 20, 2006 (edited) I am scripting the unpacking of a long list of files. I have the source *.zip files and their destination folders in an array, where I read them out and send them to a function that automates WinZip32.exe's GUI. The problem is when the zip file is very small, there is almost no indication at all that the extraction was completed. The "Extracting..." window doesn't come up (or flashes to fast to be seen). The green status light flickers for only a fraction of a second... and that's it.Does anybody know of a good way to determine that the extraction started, and then that it completed, when it goes by so fast?As a possible alternative, can the native file extraction that was added to XP/2003 and up be called directly by Run(), COM object, or DLL? Update: A little Googling found a couple of methods in MSDN for a "CIM_LogicalFile" class with "Uncompress" and "UncompressEx" listed, BUT... they both also say "This method is currently not implemented by WMI." So maybe that's no help at all. Edited June 20, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 20, 2006 Author Share Posted June 20, 2006 ...give it a little... BUMP! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Simucal Posted June 20, 2006 Share Posted June 20, 2006 (edited) Why dont you use the WinXP Com object to extract your zip files rather than automate a gui program?http://www.autoitscript.com/forum/index.ph...ic=21004&hl=zipEDIT:Func _UnZip( $sZip,$sDest) If not StringLen(Chr(0)) Then Return SetError(1) If not FileExists($sZip) Then Return SetError(2) Local $oShell = ObjCreate('Shell.Application') If @error or not IsObj($oShell) Then Return SetError(3) Local $oFolder = $oShell.NameSpace($sZip) ; Local $oDest.$oShell.Namespace(@TempDir) If @error or not IsObj($oFolder) Then Return SetError(4) Local $oItems = $oFolder.Items() If @error or not IsObj($oItems) Then Return SetError(5) if Not FileExists($sDest) Then if DirCreate($sDest)<> 1 Then Return SetError(7) EndIf $oDest =$oShell.NameSpace($sDest) If @error or not IsObj($oDest ) Then Return SetError(6) $oDest.CopyHere($oItems) EndFuncEDIT 2: OHHHH how I miss the AutoIt tags already!! I've barely had 1week+ and I feel an emptyness... a void in my life that can only be filled by those sweet, sweet tags. Edited June 20, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
dirtymafia Posted June 20, 2006 Share Posted June 20, 2006 most I would think would have a command line option to do your extraction also. In that case you would just do a Runwait and it would wait for it to complete and then move on to the next one in the list. I know WinRAR has cmd line options, not sure on winzip, but I would figure they would. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 20, 2006 Author Share Posted June 20, 2006 Why dont you use the WinXP Com object to extract your zip files rather than automate a gui program? http://www.autoitscript.com/forum/index.ph...ic=21004&hl=zip EDIT: Func _UnZip( $sZip,$sDest) If not StringLen(Chr(0)) Then Return SetError(1) If not FileExists($sZip) Then Return SetError(2) Local $oShell = ObjCreate('Shell.Application') If @error or not IsObj($oShell) Then Return SetError(3) Local $oFolder = $oShell.NameSpace($sZip) ; Local $oDest.$oShell.Namespace(@TempDir) If @error or not IsObj($oFolder) Then Return SetError(4) Local $oItems = $oFolder.Items() If @error or not IsObj($oItems) Then Return SetError(5) if Not FileExists($sDest) Then if DirCreate($sDest)<> 1 Then Return SetError(7) EndIf $oDest =$oShell.NameSpace($sDest) If @error or not IsObj($oDest ) Then Return SetError(6) $oDest.CopyHere($oItems) EndFunc EDIT 2: OHHHH how I miss the AutoIt tags already!! I've barely had 1week+ and I feel an emptyness... a void in my life that can only be filled by those sweet, sweet tags. Oooh... you rock! Now I've got two techniques to play with. I dug around in RegEdit and found the Compressed Folder handler. By manually running it on the commandline I can open the .zip file as though it was a folder: rundll32.exe ziffldr.dll,RouteTheCall "C:\Temp\MySmallZipFile.zip" I figured this could be done slicker will a DLL call from inside AuotIT, but I like your COM object even better, if I can make it work. I'm working on half a borrowed clue on COM right now, just learning it. So the answer to your first question is... ignorance! I also noticed the failure of the AutoIT tags today, even though the button is still there on the posting form. Bummer, I like that feature. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 20, 2006 Author Share Posted June 20, 2006 most I would think would have a command line option to do your extraction also. In that case you would just do a Runwait and it would wait for it to complete and then move on to the next one in the list.I know WinRAR has cmd line options, not sure on winzip, but I would figure they would.WinZip has chosen to split their commandline support out as a seperate module, downloadable only for lincensed WinZip Pro 10.0 and higher. We have a paid enterprise license for WinZip 9.0 SR1 without the commandline add on. Makes me think bad thoughts about WinZip, and now I want to see how far we can get without them! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
dirtymafia Posted June 20, 2006 Share Posted June 20, 2006 WinZip has chosen to split their commandline support out as a seperate module, downloadable only for lincensed WinZip Pro 10.0 and higher. We have a paid enterprise license for WinZip 9.0 SR1 without the commandline add on. Makes me think bad thoughts about WinZip, and now I want to see how far we can get without them! That is complete BS. Link to comment Share on other sites More sharing options...
Simucal Posted June 20, 2006 Share Posted June 20, 2006 That is complete BS.I havent used WinZip since I ran into WinRar a few years back. I like it much better... AND it has command line support! AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 20, 2006 Author Share Posted June 20, 2006 I havent used WinZip since I ran into WinRar a few years back. I like it much better... AND it has command line support! Can't argue with that, but I have to work with what they already have on their servers. BTW, in your code above, what's the purpose of the first line inside the function? If not StringLen(Chr(0)) Then Return SetError(1) What is that checking for? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Rotahn Posted June 20, 2006 Share Posted June 20, 2006 I knew there was a reason i loved 7-zip soooo much Rotahn Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2006 Author Share Posted June 21, 2006 (edited) I knew there was a reason i loved 7-zip soooo much RotahnBig catch with 7-zip (which I did like and use) is that it is NOT free in corporate or government use. That throws it out for me, outside of my personal Windows boxes, and I don't have any personal machines with Windows anymore. Correction: I went back to download 7-zip to a USB stick for a friends laptop and the 7-zip site says it is lincensed under LGPL! Way cool! From 7-zip.org FAQ page:Can I use the source code of 7-Zip in a commercial application?Since 7-Zip is licensed under the GNU LGPL you must follow the rules of that license. In brief, it means that any LGPL'ed code must remain licensed under the LGPL. For instance, you can change the code from 7-Zip or write a wrapper for some code from 7-Zip and compile it into a DLL but the source code of that DLL (including your modifications / additions / wrapper) must be licensed under the LGPL or GPL. Other code of your application can be licensed as you wish. This scheme allows users and developers to change LGPL'ed code and recompile that DLL. That is idea of free software. Read more here: http://www.gnu.org/. You can also read about the LZMA SDK, which is available under a more liberal license.My appologies to a great project for mis-reporting their lincense status. 7-zip rocks, and rocks freely! Edited June 24, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Simucal Posted June 21, 2006 Share Posted June 21, 2006 Can't argue with that, but I have to work with what they already have on their servers. BTW, in your code above, what's the purpose of the first line inside the function? If not StringLen(Chr(0)) Then Return SetError(1) What is that checking for? Honestly, I'm not sure. The function was taken from that forum I linked. It was just way down in the post so I reposted it here. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc) Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2006 Author Share Posted June 21, 2006 Honestly, I'm not sure. The function was taken from that forum I linked. It was just way down in the post so I reposted it here.Ahh, I found it there in Post #17 by erifash:It is used to check the version of AutoIt you have. Since it needs to handle character 0 in the for...next loop it needs to be higher than 3.1.1.76 (I think) because that was when binary support was added.I'm dropping that line, because nothing in any of my scripts works in Prod anyway! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2006 Author Share Posted June 21, 2006 Okay, with lots of stuff from Thread #21004 in Scripts And Scraps, I've got my Zip UDF's ready to test, and the first one fails right off the bat (the testing of the others is commented out at this point, one thing at a time). The only function being tested so far is _ZipCreate(), which should just create an empty zip file and return status. It says (by the error code) it is failing to write to the file, but the file is created and looks good. Am I missing something in how I handled error reporting?Here's the log file result:2006-06-21 13:14:03 : Starting test............. 2006-06-21 13:14:03 : Return code from _ZipCreate($ZipFile) = 0 and @Error = 2and here's the code:expandcollapse popup; Test native Zip functions with COM objects #include <file.au3> ; Parameters for test $ZipFile = @ScriptDir & "\ZipTest.zip" ; Run the test _FileWriteLog($LogFile, "Starting test.............") ; Create zip file $RetCode = _ZipCreate($ZipFile) _FileWriteLog($LogFile, "Return code from _ZipCreate($ZipFile) = " & $RetCode & " and @Error = " & @error) ;---------------------------------- ; Function _ZipCreate($sZip) ; Creates an empty .zip archive file. ; Where: $sZip is the .zip file to create ; Returns 1 on success, 0 for fail ; On fail, @Error is: ; 1 = FileOpen failed ; 2 = FileWrite failed ;---------------------------------- Func _ZipCreate($sZip) ; Create header data Local $sHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) For $i = 1 To 18 $sHeader &= Chr(0) Next ; Create empty zip file $hFile = FileOpen($sZip, 8 + 2); Mode = Create folder, Overwrite If $hFile <> - 1 Then If FileWrite($hFile, $sHeader) Then FileClose($hFile) Return 1 Else Return SetError(2, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_ZipCreate Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted June 21, 2006 Share Posted June 21, 2006 No Change to code except added at the top $LogFile = @ScriptDir & "\Zip.log" Results 2006-06-21 12:34:31 : Starting test............. 2006-06-21 12:34:31 : Return code from _ZipCreate($ZipFile) = 1 and @Error = 0 Worked just fine. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Uten Posted June 21, 2006 Share Posted June 21, 2006 Just of of curiosity. Why use winzip? with 7z you have scripting power at your fingertips From the help file: 7za.exe is a standalone version of 7-Zip. 7za.exe supports only 7z, zip, gzip, bzip2, Z and tar formats. 7za.exe doesn't use other modules.So: RunWait('7za.exe x "' $pathNameZipFile & '"')Should work as long as 7za is in a PATH folder. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2006 Author Share Posted June 21, 2006 (edited) Just of of curiosity. Why use winzip? with 7z you have scripting power at your fingertips From the help file: So: RunWait('7za.exe x "' $pathNameZipFile & '"')Should work as long as 7za is in a PATH folder. I am working an install job where WinZip 9.0 SR1 is installed, and I don't want to install anything extra to the servers. In addition, the license for 7-zip (which is great, a I used it back when I had personal Windows boxes) does not allow Corporate/Government use without enterprise licensing. (This came up in an earlier post in this thread.) Update: I went back to download 7-zip to a USB stick for a friends laptop and the 7-zip site says it is lincensed under LGPL! Way cool! From 7-zip.org FAQ page: Can I use the source code of 7-Zip in a commercial application? Since 7-Zip is licensed under the GNU LGPL you must follow the rules of that license. In brief, it means that any LGPL'ed code must remain licensed under the LGPL. For instance, you can change the code from 7-Zip or write a wrapper for some code from 7-Zip and compile it into a DLL but the source code of that DLL (including your modifications / additions / wrapper) must be licensed under the LGPL or GPL. Other code of your application can be licensed as you wish. This scheme allows users and developers to change LGPL'ed code and recompile that DLL. That is idea of free software. Read more here: http://www.gnu.org/. You can also read about the LZMA SDK, which is available under a more liberal license. My appologies to a great project for mis-reporting their lincense status. 7-zip rocks, and rocks freely! Edited June 24, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2006 Author Share Posted June 21, 2006 No Change to code except added at the top $LogFile = @ScriptDir & "\Zip.log" Results 2006-06-21 12:34:31 : Starting test............. 2006-06-21 12:34:31 : Return code from _ZipCreate($ZipFile) = 1 and @Error = 0 Worked just fine. Hmm... I trimmed all my extraneous stuff when posting, so I had a $LogFile defined (obviously since I got a log result) that I just failed to post. I'm running Beta .118, which is a few revs back. I'll try again with the latest and repost... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 21, 2006 Author Share Posted June 21, 2006 (edited) Hmm... I trimmed all my extraneous stuff when posting, so I had a $LogFile defined (obviously since I got a log result) that I just failed to post. I'm running Beta .118, which is a few revs back. I'll try again with the latest and repost... Sure enough, it fails in Beta 118, works in Beta 127. The whole thing looks like it works now. I've split it into a test script and the UDF file _ZipFunctions.au3. Here is the test script (to use the test create a C:\TestDest folder and put some stuff in it to zip): ; Test _ZipFunctions.au3 UDF file #include <file.au3> #include <array.au3> #include <_ZipFunctions.au3> ; Parameters for test $LogFile = @ScriptDir & "\ZipTestLog.log" $SrcFile = @ScriptFullPath $SrcFolder = "C:\ZipTestSrc" $ZipFile = @ScriptDir & "\ZipTest.zip" $DestFolder = "C:\ZipTestDest" ; Run the test _FileWriteLog($LogFile, "Starting test.............") ; Create zip file $RetCode = _ZipCreate ($ZipFile) _FileWriteLog($LogFile, "Return code from _ZipCreate($ZipFile) = " & $RetCode & " and @Error = " & @error) ; Add a single file $RetCode = _ZipAdd ($ZipFile, $SrcFile) _FileWriteLog($LogFile, "Return code from _ZipAdd($ZipFile, $SrcFile) = " & $RetCode & " and @Error = " & @error) ; Add a folder $RetCode = _ZipAdd ($ZipFile, $SrcFolder) _FileWriteLog($LogFile, "Return code from _ZipAdd($ZipFile, $SrcFolder) = " & $RetCode & " and @Error = " & @error) ; List the contents of the zip file $list = _ZipList ($ZipFile) _FileWriteLog($LogFile, "List returned from _ZipList($ZipFile) with @Error = " & @error) _ArrayDisplay($list, "Results for: _ZipList($ZipFile)") ; Unzip to a new location $RetCode = _UnZip ($ZipFile, $DestFolder) _FileWriteLog($LogFile, "Return code from _UnZip($ZipFile, $DestFolder) = " & $RetCode & " and @Error = " & @error) And here is the code for _ZipFunctions.au3: expandcollapse popup#include-once ;====================================== ; _ZipFunctions.au3 -- v1.0 -- 20 June, 2006 ; An AutoIT User Defined Function (UDF) file. ; ; Requires AutoIT 3.1.127 or later. ; Uses the native compression API of Windows XP, Windows 2003, or later. ; ; By PsaltyDS at http://www.autoitscript.com/forum ; Includes code from other forum users, especially as posted at: ; http://www.autoitscript.com/forum/index.php?showtopic=21004 ; ; Includes the following functions: ; _ZipCreate($sZip, $iFlag = 0) ; _ZipAdd($sZip, $sSrc) ; _ZipList($sZip) ; _UnZip($sZip, $sDest) ; See each function below for full usage. ;====================================== ;---------------------------------- ; Function _ZipCreate($sZip, $iFlag = 0) ; Creates an empty .zip archive file. ; Where: ; $sZip is the .zip file to create ; $iFlag: 0 = prompts to overwrite (default) ; 1 = overwrite without prompt ; Returns 1 on success, 0 for fail ; On fail, @Error is: ; 1 = Not permitted to overwrite ; 2 = FileOpen failed ; 3 = FileWrite failed ;---------------------------------- Func _ZipCreate($sZip, $iFlag = 0) ; Test zip file If FileExists($sZip) Then If Not $iFlag Then If MsgBox(32 + 4, "Zip Functions UDF", "Click YES to overwrite existing archive file: " & @CRLF & _ @TAB & $sZip) <> 6 Then Return SetError(1, 0, 0) EndIf EndIf ; Create header data Local $sHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) For $i = 1 To 18 $sHeader &= Chr(0) Next ; Create empty zip file $hFile = FileOpen($sZip, 16 + 8 + 2); Mode = Binary, Create folder, Overwrite If $hFile <> - 1 Then If FileWrite($hFile, $sHeader) Then FileClose($hFile) Return 1 Else Return SetError(3, 0, 0) EndIf Else Return SetError(2, 0, 0) EndIf EndFunc ;==>_ZipCreate ;---------------------------------- ; Function _ZipAdd($sZip, $sSrc) ; Adds a file or folder to a pre-existing .zip archive. ; Where: ; $sZip is the .zip file to add to ; $sSrc is the source file or folder to add ; Returns 1 on success, 0 for fail ; On fail, @Error is: ; 1 = Creating Zip file failed [@Extended = @Error from _ZipCreate()] ; 2 = Source did not exist ; 3 = Shell ObjCreate error ; 4 = Zip file namespace object error ; 5 = Error copying data ;---------------------------------- Func _ZipAdd($sZip, $sSrc) ; Test zip file and create if required If Not FileExists($sZip) Then If Not _ZipCreate($sZip) Then Return SetError(1, @error, 0) EndIf ; Test source If FileExists($sSrc) Then ; Create shell object Local $oShell = ObjCreate('Shell.Application') If Not @error And IsObj($oShell) Then ; Get zip file object Local $oFolder = $oShell.NameSpace ($sZip) If Not @error And IsObj($oFolder) Then ; Copy source file or folder to zip file If StringInStr(FileGetAttrib($sSrc), "D") Then $oFolder.CopyHere ($oShell.NameSpace ($sSrc).items) Else $oFolder.CopyHere ($sSrc) EndIf Sleep(1000) If @error Then Return SetError(5, 0, 0) Else Return 1 EndIf Else Return SetError(4, 0, 0) EndIf Else Return SetError(3, 0, 0) EndIf Else Return SetError(2, 0, 0) EndIf EndFunc ;==>_ZipAdd ;---------------------------------- ; Function _ZipList($sZip) ; List the contents of a .zip archive file ; Where: $sZip is the .zip file ; On Success, returns a 1D array of items in the zip file, with [0]=count ; On fail, returns array with [0]=0 and @Error is: ; 1 = Zip file did not exist ; 2 = Shell ObjCreate error ; 3 = Zip file namespace object error ; 4 = Error copying data ;---------------------------------- Func _ZipList($sZip) Local $aNames[1] =[0], $i ; Test zip file If FileExists($sZip) Then ; Create shell object Local $oShell = ObjCreate('Shell.Application') If Not @error And IsObj($oShell) Then ; Get zip file object Local $oFolder = $oShell.NameSpace ($sZip) If Not @error And IsObj($oFolder) Then ; Get list of items Local $oItems = $oFolder.Items () If Not @error And IsObj($oItems) Then ; Read items into array For $i In $oItems $aNames[0] += 1 ReDim $aNames[$aNames[0] + 1] $aNames[$aNames[0]] = $oFolder.GetDetailsOf ($i, 0) Next Else SetError(4) EndIf Else SetError(3) EndIf Else SetError(2) EndIf Else SetError(1) EndIf Return $aNames EndFunc ;==>_ZipList ;---------------------------------- ; Function _UnZip($sZip, $sDest) ; Uncompress items from a .zip file a destination folder. ; Where: ; $sZip is the .zip file ; $sDest is the folder to uncompress to (without trailing '\') ; Returns 1 on success, 0 for fail ; On fail, @Error is: ; 1 = Source zip file did not exist ; 2 = Error creating destination folder ; 3 = Shell ObjCreate error ; 4 = Zip file namespace object error ; 5 = Error creating item list object ; 6 = Destination folder namespace object error ; 7 = Error copying data ;---------------------------------- Func _UnZip($sZip, $sDest) ; Test zip file If FileExists($sZip) Then ; Test destination folder If Not FileExists($sDest & "\") Then If Not DirCreate($sDest) Then Return SetError(2, 0, 0) EndIf ; Create shell object Local $oShell = ObjCreate('Shell.Application') If Not @error And IsObj($oShell) Then ; Get zip file namespace object Local $oFolder = $oShell.NameSpace ($sZip) If Not @error And IsObj($oFolder) Then ; Get list of items in zip file Local $oItems = $oFolder.Items () If Not @error And IsObj($oItems) Then ; Get destination folder namespace object $oDest = $oShell.NameSpace ($sDest & "\") If Not @error And IsObj($oDest) Then ; Copy the files $oDest.CopyHere ($oItems) Sleep(500) If @error = 0 Then Return 1 Else Return SetError(7, 0, 0) EndIf Else Return SetError(6, 0, 0) EndIf Else Return SetError(5, 0, 0) EndIf Else Return SetError(4, 0, 0) EndIf Else Return SetError(3, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_UnZip My test resulted in the following log file output: 2006-06-21 15:29:20 : Starting test............. 2006-06-21 15:29:20 : Return code from _ZipCreate($ZipFile) = 1 and @Error = 0 2006-06-21 15:29:21 : Return code from _ZipAdd($ZipFile, $SrcFile) = 1 and @Error = 0 2006-06-21 15:29:22 : Return code from _ZipAdd($ZipFile, $SrcFolder) = 1 and @Error = 0 2006-06-21 15:29:22 : List returned from _ZipList($ZipFile) with @Error = 0 2006-06-21 15:29:29 : Return code from _UnZip($ZipFile, $DestFolder) = 1 and @Error = 0 Thanks for the massive help from everybody! Edit: Changed FileOpen() parameters in _ZipCreate() for binary mode. Thanks to snaxau for pointing out the problem! Edited November 22, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Uten Posted June 22, 2006 Share Posted June 22, 2006 I am working an install job where WinZip 9.0 SR1 is installed, and I don't want to install anything extra to the servers. In addition, the license for 7-zip (which is great, a I used it back when I had personal Windows boxes) does not allow Corporate/Government use without enterprise licensing. (This came up in an earlier post in this thread.) Ohhh, I searched for 7z in this thread before posting. :"> I was not aware of the enterprise licensing restriction I take it you know about info-zip's dll's. It claims to be free to but I have not read the license . And I'm not sure it supports the latest compression techniques used by winzip and others (as the ultra level in 7-zip). The zip format is supposed to be a standard but you know... Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
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