How to create a zip folder using VBScript

Below function will create the zip folder and hep you to upload big testing artifacts as attachment in ALM:

    ZipAttach = ""

    ' Declare the required variables
    Dim objZip, objSA, objFolder, zipFile, FolderToZip
   
    FolderToZip = strFoldertoZip
    zipFile = strFoldertoZip & ".zip"
    'FolderToZip = Environment.Value(<ResultFolder on local drive>)
   

    'Create the basis of a zip file.
    CreateObject("Scripting.FileSystemObject") _
    .CreateTextFile(zipFile, True) _
    .Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

    ' Create the object of the Shell
    Set objSA = CreateObject("Shell.Application")
   
    ' Add the folder to the Zip
    Set objZip = objSA.NameSpace(zipFile)
    Set objFolder = objSA.NameSpace(FolderToZip)
    objZip.CopyHere(objFolder.Items)

    wait(10)

    ZipAttach = zipFile

Comments

Popular posts from this blog

UFT - Resolving scrolling issue if object is not visible

how to access the excel file as database in UFT?