我在压缩批处理文件中的目录或文件时遇到问题。我该怎么做,有人可以帮我吗?
谢谢
对于 SuperUser上的 Post 上的类似问题有一个很好的解决方案,我已将其复制粘贴在下面。
CScript zip.vbs C:\test3 C:\someArchive.zip
其中 zip.vbs 包含以下内容
'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
在这里您可以找到两种不使用任何外部工具的方法。
最好使用使用 Shell.Application 对象的WSH/Jscript 脚本。