首页  编辑  

脚本压缩文件

Tags: /计算机文档/脚本,批处理/   Date Created:

在脚本中压缩文件

Option Explicit

Dim oFSO, oShell, oFile, zipFil

Dim strFile, strZip

strFile = "c:\RCU70315124500.rcu"

strZip = "C:\MyBackup.zip"

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set oShell = CreateObject("Shell.Application")

Set oFile = oFSO.GetFile(strFile)

Set zipFil = oFSO.CreateTextFile(strZip)

zipFil.WriteLine Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)

zipFil.Close

oShell.NameSpace(strZip).CopyHere oFile.Path

wscript.sleep 2000 ' need enough time to finish the copy action, otherwise the zip file is corrupt

Set zipFil = Nothing

Set oShell = Nothing

Set oFile = Nothing

set oFso=Nothing

wscript.quit