VBScript调用RAR压缩文件...

本文介绍了一种使用VBScript来调用RAR压缩工具的方法,实现了文件夹内所有文件的备份与压缩。通过创建文件系统对象及调用WScript.Shell对象的方法,实现了指定文件的压缩操作。

 

VBScript调用RAR压缩文件

 

 

'------------------------------------------------------------

'Backup Data File and Rar File

'Create Date: 2009-11-05

'Author:   Wei_Zhu

'Chage Log:

'Last Chage Date: 2009-11-05

'-------------------------------------------------------------

 

BackUpFile("D:/Data")

 

Function BackUpFile(lstg_folder_name)

Dim fso, f, f1,fc,s,folder

    Set fso=CreateObject("Scripting.FileSystemObject")

    folder=fso.getfolder(ws.currentdirectory)

    Set f=fso.GetFolder(lstg_folder_name)

    Set fc=f.files

    For Each f1 in fc

       dim lf

       lf=lstg_folder_name& "/" & f1.name

       RarFile lf

    Next

End Function

 

'----Rar File-----

Function RarBackupFile(lastg_file_name)

'/*Rar Program in RarComponent Folder, Program Name is Rar.exe

'  Rar Source: Folder + File

'  Rar Target: Folder + Target Name .rar */

    Dim WshShell

    Set WshShell = CreateObject("WScript.Shell")

    Set fso=CreateObject("Scripting.FileSystemObject")

    folder=fso.getfolder(WshShell.currentdirectory)

    RarComponent =folder&"/RarComponent/rar.exe"

    SourceFile = lastg_file_name

    TargetFile = "D:/data/test.rar"

    WshShell.Run RarComponent&" a -ep1 "&TargetFile&" "&SourceFile,0

End Function

 

 

转载于:https://www.cnblogs.com/sesexxoo/archive/2009/11/05/6190172.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值