进行自动备份的脚本

 dim ip
dim userName
dim pwd
dim copyVss
dim backupFolder
dim fso
dim ts
dim wshshell

ip = ""
userName = ""
pwd = ""
backupFolder = ""

redim copyVss(2)
copyVss(0) = ""
copyVss(1) = ""

set fso = CreateObject("Scripting.FileSystemObject")
if not fso.fileexists(backupFolder & "backup.txt") then
 fso.createtextfile backupFolder & "backup.txt",true
end if
set ts = fso.OpenTextFile(backupFolder & "backup.txt", 2)

set wshshell = wscript.createobject("wscript.shell")
RetCode = wshshell.run("net use " & ip & " " & pwd & " /user:" & userName , 0, true )
if RetCode <> 0 then
 set wshshell = nothing
 ts.writeline("---  " & ip & "    " & date & " " & time)
 ts.close()
 set ts = nothing
 set fso = nothing
 wscript.quit()
end if

ts.writeline("=========  START:  " & date & " " & time & "==========")
ts.writeline("")

Call backupfile()

ts.writeline("")
ts.writeline("=========   END:  " & date & " " & time & "==========")

wshshell.run "net use " & ip & " /delete"

set wshshell = nothing
ts.close()
set ts = nothing
set fso = nothing

sub backupfile()
on error resume next
dim tmpCommand

for i = 0 to UBound(copyVss) - 1
 tmpCommand = ""

 tmpCommand = backupFolder & copyVss(i)
 if not fso.FolderExists(tmpCommand) then
  fso.CreateFolder tmpCommand
 end if

 tmpCommand = "xcopy " & """" & ip & "/"& copyVss(i) & """" &" /s/e/y " & """" & tmpCommand & """"
 RetCode = wshshell.run(copyCommand , 1, true)
 
 if RetCode <> 0 then
  ts.writeline("---  "& ip & "/"& copyVss(i) &"   failure : " & RetCode & " "  & date &" "& time)
 else
  ts.writeline("---  "& ip & "/"& copyVss(i) &"   success : " & date &" "& time & "--- OK!")
 end if
next

end sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值