局域网文件自动备份 VBS 脚本

' =============== 局域网文件自动备份 VBS 脚本 =================
'
' 条件:10.97.1.X 开用户xcopy/xcopy 属于adminstrator
' 共享BACKUP 文件所在目录,使xcopy 用户完全控制!
' 运行后在管理进程中有2个进程:wscript.exe,ping.exe
' 以日期为log文件名称,只保留7天的日志
'
' =============================================================

Do While True
dim f,txtfile

Set f = CreateObject("Scripting.FileSystemObject")
set txtfile = f.opentextfile("D:/web/barcodeprinter/BACKUP/"&date&".txt",8,True)

'==== 判定7天前的log 文件是否存在,存在则删除!
If f.FileExists("D:/web/barcodeprinter/BACKUP/"&date-5&".txt") Then
   f.DeleteFile("D:/web/barcodeprinter/BACKUP/"&date-5&".txt")
end if
'====

txtfile.writeline("========= 实时备份开始:  "&date&" "&time&"==========")
txtfile.writeline(" ")
    Call backupfile(f,txtfile)
    WScript.Sleep 10000

txtfile.writeline("========= 实时备份结束:  "&date&" "&time&"==========")
txtfile.writeline("")

set f =nothing
set txtfile=nothing

Loop

'------------------------------------ 实时备份过程 -----------------------------------
sub backupfile(f,txtfile)
Dim Path,fso,net
num=1
do while num<10

if num=1 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪"
 target_path="BACKUP/barcodeprinter31.mdb"
end if

if num=2 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪"
 target_path="BACKUP/barcodeprinter32.mdb"
end if

if num=3 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪"
 target_path="BACKUP/barcodeprinter33.mdb"
end if

if num=4 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪"
 target_path="BACKUP/barcodeprinter34.mdb"
end if

if num=5 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/qjcf_no1"
 target_path="BACKUP/barcodeprinter35.mdb"
end if

if num=6 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪(BarCodePrinter)"
 target_path="BACKUP/barcodeprinter36.mdb"
end if

if num=7 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪(BarCodePrinter)"
 target_path="BACKUP/barcodeprinter37.mdb"
end if

if num=8 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪"
 target_path="BACKUP/barcodeprinter38.mdb"
end if

if num=9 then
 ip="10.97.1.3"&num
 source_path="//"&ip&"/产品数码跟踪(BarCodePrinter)"
 target_path="BACKUP/barcodeprinter39.mdb"
end if

'
ip="10.97.1.3"&num
source_path="//"&ip&"/产品数码跟踪"
target_path="D:/WEB/barcodeprinter/BACKUP/barcodeprinter3"&num&".mdb"  


'------------ ping 测试,网络通ping="T"; -------------------
Set FileSys   =   CreateObject("Scripting.FileSystemObject")
Set WShShell   =  CreateObject("WScript.Shell")   
RetCode   =   WShShell.Run("ping " &IP , 0, True ) 

if   RetCode   =   0   Then  ' ping 测试通过
 ping="T"
else
 ping="F"
end if
 
set filesys  = nothing
set wshshell = nothing

'------------ ping 结束 ------------------------------------

if ping="T" then

On Error Resume Next '出错不显示,执行下一条
Path="X:"
Set fso = CreateObject("Scripting.FileSystemObject")
Set net = CreateObject("WScript.Network")

If Not fso.DriveExists(fso.GetDriveName(Path)) Then
net.MapNetworkDrive Path,source_path,False,"xcopy","xcopy"
End If

Set file = fso.GetFile(Path&"/barcodeprinter.mdb") 
file.Copy(target_path)    

net.RemoveNetworkDrive Path,True

If Err.Number<>0 Then
txtfile.writeline("---  "&ip&"   备份失败! "&date&" "&time)
else
txtfile.writeline("---  "&ip&"   备份成功! "&date&" "&time&"--- OK!")
end if

else
txtfile.writeline("---  "&ip&"   网络不通! "&date&" "&time)
end if


set fso=nothing
set net=nothing

num=num+1
loop

end sub
'------------------------------------ 实时备份过程 ----------------------------------- 

可以在局域网中发送消息的vbs程序,小巧,易用 go.exe 命令参数: /p 图片路径 [-L1 -L2 -H1 -H2 -B1 -Q1] /z 公告内容 /t 公告时长 /n 网吧名称 /u 网址 --------------------------------------------------------------------------------------------- /p 背景路径 /z 公告内容 /t 公告时长 /n 网吧属名 /u 给公告加连接 ( /p /z /n /t )四位参数的组合使用或其中三位与三位以下参数组合时候,参数不分前后,加上/U时一定要按指定格式书写! '当公告在执行的其间,任务管理器失效,自动退出后,任务管理器复原! 1.增加/u参数 必须用上 /p /z /t /n 四个参数之时,/u才存在,否则都会出错!而且要以下面的顺序格式才OK! ----------------------------------------------------------------------------------------------- 1 2 3 4 5 < /p 图片路径 /z 公告内容 /t 公告时长 /n 网吧名称 /u 网址> 例: go /n 盈众网吧 /p Background.jpg /z 请注意好您的贵重物品 /t 5 /u http:\\www.sina.com.cn (注意:网址的斜线必须为"\") ----------------------------------------------------------------------------------------------- 2.增加六种颜色: (注意: 必须使用在公告内存后面,下面有例子) ----------------------------------------------------------------------------------------------- <-L1> <-L2> <-H1> <-H2> <-B1> <-Q1> ~~~字母匀为大写,小写无效~~~~ 蓝 绿 红 黄 白 青 例: go /z 请注意好您的贵重物品,如有丢失,本网吧概不负责 -B1 /t 3 ----------------------------------------------------------------------------------------------- 3. 去掉了广告 4. 加动态移出! 5.链接为“公告内容”
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值