1
votes

Below is my script

zIP Script

wvar1 = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "\Dumps"
wvar2 = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "\Dumps.zip"
set wshell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

ArchiveFolder wvar2, wvar1

Sub ArchiveFolder (zipFile, sFolder)

    With CreateObject("Scripting.FileSystemObject")
        zipFile = .GetAbsolutePathName(zipFile)
        sFolder = .GetAbsolutePathName(sFolder)

        With .CreateTextFile(zipFile, True)
            .Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, chr(0))
        End With
    End With

    With CreateObject("Shell.Application")
        .NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items

        Do Until .NameSpace(zipFile).Items.Count = _
                 .NameSpace(sFolder).Items.Count
            WScript.Sleep 1000 
        Loop
    End With

End Sub

unzIP Script

Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile) 
ZipFile = "" & strFolder & "\Scripts\Dumper_AV.zip" & ""
ExtractTo= var1
 
Set fso = CreateObject("Scripting.FileSystemObject")
sourceFile = fso.GetAbsolutePathName(ZipFile)
destFolder = fso.GetAbsolutePathName(ExtractTo)
 
Set objShell = CreateObject("Shell.Application")
Set FilesInZip=objShell.NameSpace(sourceFile).Items()
objShell.NameSpace(destFolder).copyHere FilesInZip, 16
Set fso = Nothing
Set objShell = Nothing
Set FilesInZip = Nothing

But i wanted it hidden to zip silently, but it opens up a progress box displaying compressing same with my unzip script. is there a way to hide it.

As per docs vOptions 4 to hide progress is being ignored

Solved Hidden Unzipping But solution required for hidden Zipping

2
If you want to try with a powershell script into a vbscript using the cmdlet Compress-Archive : Compress_Archive_by_Extension.vbs - Hackoo

2 Answers

0
votes

Note the second parameter to CopyHere.

 .NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items, 4

From the docs

Folder.CopyHere(
  vItem,
  [ vOptions ]
)

...

(4)

Do not display a progress dialog box.

https://docs.microsoft.com/en-us/windows/win32/shell/folder-copyhere

0
votes

Partial Solution

For UNZIP Script Only

Trick 1 : Use Vbsedit to compile vbscript to exe and it will execute silently

Trick 2 : .NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items, &H4

Note: As per docs .NameSpace(zipFile).CopyHere .NameSpace(sFolder).Items, 4 doesn't work. vOption variable 4 need to be converrted to Hex string &H4 to make it work