[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
第三方压缩工具不想找。可以用vbs实现(不是很完美)
  1. '&@cls&cscript -nologo -e:vbs "%~f0"&exit/b
  2. strSrc = "C:\aaa.rom" '需要被压缩的文件
  3. strZip = "C:\test.zip" 'zip压缩文件
  4. strDst = "\roms" 'zip压缩文件中的指定目录
  5. set ws = CreateObject("WScript.Shell")
  6. set oShell = CreateObject("Shell.Application")
  7. set oZip = oShell.NameSpace(strZip & strDst)
  8. oZip.CopyHere strSrc, 4+16 '参数设置无效,还是有进度条(但正好为异步等待提供了一个检验窗口)
  9. do 'CopyHere方法似乎是异步的,必须等待以便复制完成。
  10. wsh.sleep 200
  11. loop while ws.AppActivate("正在压缩...")
复制代码
命令行参考:hh.exe ntcmds.chm::/ntcmds.htm
求助者请拿出诚心,别人才愿意奉献热心!
把查看手册形成条件反射!

TOP

回复 5楼 的帖子

改进了一下,根据已经复制的大小判断是否全部压缩完成
  1. '&@cls&cscript -nologo -e:vbs "%~f0"&exit/b
  2. strSrc = "C:\aaa.rom" '需要被压缩的文件
  3. strZip = "C:\test.zip" 'zip压缩文件
  4. strDst = "\roms" 'zip压缩文件中的指定目录
  5. set fso = CreateObject("Scripting.FileSystemObject")
  6. intSrcSize = fso.GetFile(strSrc).Size
  7. strFile = fso.GetFileName(strSrc)
  8. set oShell = CreateObject("Shell.Application")
  9. 'oShell.ShellExecute "regsvr32", "/s zipfldr.dll" '重新注册可能被优化掉的zipfldr.dll
  10. 'wsh.sleep 1000
  11. set oZip = oShell.NameSpace(strZip & strDst)
  12. oZip.CopyHere strSrc, 4+16
  13. do
  14. wsh.sleep 200
  15. loop while oZip.ParseName(strFile).Size < intSrcSize
复制代码
命令行参考:hh.exe ntcmds.chm::/ntcmds.htm
求助者请拿出诚心,别人才愿意奉献热心!
把查看手册形成条件反射!

TOP

奇怪了,今天在某个网吧上网,发现CopyHere的参数设置是有效的。但我上次在公司电脑上测试不管参数设置成什么,还是会出现进度条。

大家帮忙测试一下。
命令行参考:hh.exe ntcmds.chm::/ntcmds.htm
求助者请拿出诚心,别人才愿意奉献热心!
把查看手册形成条件反射!

TOP

返回列表