今天写程序时突然想到做一个文件的备份,把网站上的数据库备份到本地机上。一个简单的小程序,做成可执行的文件,用VBS最简单方便了。'OnErrorResumeNext
DimiRemote,iLocal
iRemote=InputBox("请输入远程文件路径:")
SetxPost=CreateObject("Microsoft.XMLHTTP")
xPost.Open"GET",iRemote,0
xPost.Send()
Setstream=CreateObject("ADODB.Stream")
stream.Mode=3
stream.Type=1
stream.Open()
stream.Write(xPost.responseBody)
if(stream.size<10240)then
MsgBox("远程文件不存在!")
else
SaveFile
endif
stream.close
setstream=nothing
'保存文件
functionSaveFile
iLocal=InputBox("请输入本机保存路径:")
Setfso=CreateObject("Scripting.FileSystemObject")
returnValue="0"
if(fso.FileExists(iLocal))then
returnValue=MsgBox("'"&iLocal&"'文件已存在,真的要覆盖吗?",vbYesNoCancel,"确认框")
endif
setfso=nothing
if(returnValue="6"orreturnValue="0")then'覆盖
stream.SaveToFileiLocal,2
MsgBox("文件备份成功!")
elseif(returnValue="7")then
SaveFile
endif
endfunction