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