How to compress a batch file

I have a problem compressing a directory or file in a batch file. HOw can I do this, can someone help me with this?

thanks

+4
source share
3 answers

There is a good solution to a similar question in Post on SuperUser , I copied it below.

CScript zip.vbs C: \ test3 C: \ someArchive.zip

Where zip.vbs contains the following

'Get command-line arguments. Set objArgs = WScript.Arguments InputFolder = objArgs(0) ZipFile = objArgs(1) 'Create empty ZIP file. CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) Set objShell = CreateObject("Shell.Application") Set source = objShell.NameSpace(InputFolder).Items objShell.NameSpace(ZipFile).CopyHere(source) 'Required! wScript.Sleep 2000 
+2
source

You can use a third-party tool, I suggest 7-Zip , which has a command line version that you can use in batch mode.

See here for a list of commands and examples used.

0
source

Here you can find two ways without using any external tools.

It is better to use a WSH / Jscript script that uses the Shell.Application object.

0
source

All Articles