07-31-2012 07:38 AM
Hello,
I would like to ask how to pack exported data from DIAdem to zip?
Thank you for advance.
Radek
Solved! Go to Solution.
08-01-2012 01:54 AM
Hello Radek,
you can use the gnu tools for win32.
They contain two executables zip.exe and unzip.exe that you can ship for free and use a script like the following.
Takse some time to check the parameters of the two little tools.
Option Explicit 'Forces the explicit declaration of all the variables in a script.
dim zipFile : zipFile = CurrentScriptPath & "example.zip"
if FileExist(zipFile) then
FileDelete zipFile
end if
call AddToZip(zipFile, CurrentScriptPath & CurrentScriptName)
dim outPath : outPath = Unzip(zipFile)
MsgBox "Extracted to: " & outPath
Sub AddToZip(filePath, fileToAdd)
dim shell : Set shell = CreateObject("WScript.Shell")
dim zipCmd : zipCmd = CurrentScriptPath & "\zip.exe"
dim command : command = """" & zipCmd & """ -D -j """ & filePath & """ """ & fileToAdd & """"
dim status : status = shell.Run(command, 0, true)
if(0 <> status) then
err.Raise 100, "", "zip.exe failed with status " & status & "."
end if
End Sub
Function Unzip(filePath)
dim shell : Set shell = CreateObject("WScript.Shell")
dim tempDir : tempDir = shell.Environment("Process")("Temp") & "\myoutput"
dim unZipCmd : unZipCmd = CurrentScriptPath & "\unzip.exe"
dim command : command = """" & unZipCmd & """ -o """ & filePath & """ -d """ & tempDir & """"
dim status : status = shell.Run(command, 0, true)
if(0 <> status) then
err.Raise 100, "", "unzip.exe failed with status " & status & "."
end if
Unzip = tempDir
End Function
Greetings
Andreas
08-01-2012 06:17 AM
Since win XP
Sub AddToZip(zipFile, folderToZip)
dim sa : set sa = CreateObject("Shell.Application")
dim zipFileObj : Set zipFileObj = sa.NameSpace(zipFile)
dim fol : Set Fol = sa.NameSpace(folderToZip)
zipFileObj.CopyHere(Fol.Items)
End Sub
Sub Unzip(zipFile, unzipToFolder)
dim sa : set sa = CreateObject("Shell.Application")
dim filesInzip : set filesInzip = sa.NameSpace(zipFile).items
sa.NameSpace(unzipToFolder).CopyHere(filesInzip)
End Sub
seems to work too.
08-14-2012 09:39 AM
Thanks for the advice, but packing using second method does not work. I think you need to first create a Zip file, including the appropriate header, and then you can write to him.
Sub Zip(sFile, sZipFile)
Set oZipFSO = CreateObject("Scripting.FileSystemObject")
Set oZipFile = oZipFSO.CreateTextFile(sZipFile)
oZipFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
Set oZipApp = CreateObject("Shell.Application")
oZipApp.NameSpace(sZipFile).Copyhere sFile
End Sub
Some example can be seen on: http://www.naterice.com/articles/64
Radek