我有一个.bat文件,用于备份文件,该文件调用.vbs文件并将其传递给两个参数,如下所示:
... ZipCMD.vbs "C:Source" "C:DestinationData.zip" ...
ZipCMD.vbs包含以下代码(授予garbb):
Set objArgs = WScript.Arguments Set FS = CreateObject("Scripting.FileSystemObject") InputFolder = FS.GetAbsolutePathName(objArgs(0)) ZipFile = FS.GetAbsolutePathName(objArgs(1)) 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 numfolderitems = objShell.NameSpace(InputFolder).Items.count objShell.NameSpace(ZipFile).copyHere(source) ' wait until number of items in zip file is the same as in the folder we are zipping up ' also sometimes gets errors when getting folder object for zip file,probably because it is in use? so ignore these On Error Resume Next do while True numitemsinzip = objShell.NameSpace(ZipFile).Items.count If Err.Number = 0 and numitemsinzip = numfolderitems Then Exit Do ElseIf Err.Number <> 0 then Err.Clear End If wScript.Sleep 10 Loop On Error Goto 0
当发生压缩时,会出现通常窗口的“压缩文件”界面,并在closures和消失前显示进度条几分钟。
问题: vbs能否静默运行压缩(即没有界面)? – 我读过这篇文章 ,其中显示了一个标志,但是出于某种原因,这似乎不适用于复制到.zip。
除了最后一行之外,添加字符到每行的结尾
循环/ D标志的batch file不会出现在命令行中
后续问题:如果我使用的.vbs文件不可能实现这个function,那么还有其他的方法,它仍然使用调用另一个文件/进程(?)(.vbs / .js或者其他的? ),并从CMD的两个path喂它?
编辑:我试图做到这一点,而不使用第三方软件(如7zip),只是使用本机Windows代码。
Windows期望从Python返回值
如何将所有我的function作为一个单独的文件打包到一个batch file?
Windows cmdbatch file,复制源文件夹和内容
如何删除一个快捷方式,如果文件不存在于一个Windows .BAT文件?
批处理多行到单行?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。