How to Unzip a .zip file using VB Script to automatically skip any errors silently
Hi All,I am using the below VB Script to Unzip a .zip file of size 1.8GB having around 32,000+ files after Unzipping.
----------------------------------------------------------------------
Dim sCurPath
set filesys = Createobject("Scripting.FileSystemObject")
sCurpath = Replace(wscript.ScriptFullname, Wscript.ScriptName, "")
Set WshShell = CreateObject("Wscript.Shell")
ZipFile= sCurPath & "install-old.zip"
ExtractTo= "C:\InformaticaSource"
If NOT filesys.FolderExists(ExtractTo) Then
filesys.CreateFolder(ExtractTo)
End If
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
--------------------------------------------------------------------------------
While running the script on Windows 7 OS, I receive the DIALOG from "Interactive Services Detection" informing me that there is an error that I can retry,cancel or skip.
ERROR 0X80004005:Unspecified Error
This is the only error I receive and although I receive the error,I can see the file already present in the destination location with the same filesize(still I dont know why I receive the error) and I really want that the above script should automatically 'SKIP' errors when it is encountered.
Any Modifications to the above script to achieve this would be much appreciated..!! Thanks a lot for your assistance in advance..!!Kind Regards.
Answers (2)
Unzipping a file is same as copying a file in vbscript. we can use xcopy instead of a normal copy which is handle through a dos in wondows OS.
Its difficult to have end users installed 7-zip or x zip without any licences. So just unzip the file at source and copy it to the destination folder .
Zipped File --> Unzippedfolder in source
unZippedFolder = sCurPath & "install-old"
Destinationfolder= "C:\InformaticaSource"
wshShell.run ""xcopy " & sCurPath & "install-old\* " & " " & "C\InformaticaSource" & " /s /f /r /y /i /z""
\* --> Copy current folder all sub folders
/s --> To copy a folder including all subfolders.
/i --> defines the destination as folder.
/y -->Suppress prompt to confirm overwriting a file
/f-->Display full source and destination file names while copying.
/r-->Overwrite read-only files.
/z-->Copy files in restartable mode. If the copy is interrupted part way through, it will restart if possible. (use on slow networks)
hope it helps.
got the same problem sometime ago and got around using 7-zip.
7za.exe x FILE.zip -y
this extracts all files with full folders and answers alls queries with "yes" (which also skips these errors)
Other packers may work too
Comments:
-
Thanks for your response..do you have any such option (answering all queries with "skip") in VB Script..? - satyapai 11 years ago
Alternatively, you could actually try to work out *why* you're seeing the error (which I suspect translates to 'Access denied', something which ProcMon - YAAAAAAWN! - would've told you on Day One!) and code accordingly. - anonymous_9363 11 years ago