用VBS可執(zhí)行程序+Xmlhttp下載備份網(wǎng)上文件的代碼
更新時間:2007年08月08日 10:58:17 作者:
今天寫程序時突然想到做一個文件的備份,把網(wǎng)站上的數(shù)據(jù)庫備份到本地機(jī)上。一個簡單的小程序,做成可執(zhí)行的文件,用VBS最簡單方便了。 'On Error Resume Next
Dim iRemote,iLocal
iRemote = InputBox("請輸入遠(yuǎn)程文件路徑:")
Set xPost = CreateObject("Microsoft.XMLHTTP")
xPost.Open "GET",iRemote,0
xPost.Send()
Set stream = CreateObject("ADODB.Stream")
stream.Mode = 3
stream.Type = 1
stream.Open()
stream.Write(xPost.responseBody)
if (stream.size<10240) then
MsgBox("遠(yuǎn)程文件不存在!")
else
SaveFile
end if
stream.close
set stream = nothing
' 保存文件
function SaveFile
iLocal = InputBox("請輸入本機(jī)保存路徑:")
Set fso = CreateObject("Scripting.FileSystemObject")
returnValue = "0"
if (fso.FileExists(iLocal)) then
returnValue = MsgBox("'"&iLocal&"'文件已存在,真的要覆蓋嗎?",vbYesNoCancel,"確認(rèn)框")
end if
set fso = nothing
if (returnValue = "6" or returnValue = "0") then '覆蓋
stream.SaveToFile iLocal,2
MsgBox("文件備份成功!")
elseif (returnValue = "7") then
SaveFile
end if
end function
Dim iRemote,iLocal
iRemote = InputBox("請輸入遠(yuǎn)程文件路徑:")
Set xPost = CreateObject("Microsoft.XMLHTTP")
xPost.Open "GET",iRemote,0
xPost.Send()
Set stream = CreateObject("ADODB.Stream")
stream.Mode = 3
stream.Type = 1
stream.Open()
stream.Write(xPost.responseBody)
if (stream.size<10240) then
MsgBox("遠(yuǎn)程文件不存在!")
else
SaveFile
end if
stream.close
set stream = nothing
' 保存文件
function SaveFile
iLocal = InputBox("請輸入本機(jī)保存路徑:")
Set fso = CreateObject("Scripting.FileSystemObject")
returnValue = "0"
if (fso.FileExists(iLocal)) then
returnValue = MsgBox("'"&iLocal&"'文件已存在,真的要覆蓋嗎?",vbYesNoCancel,"確認(rèn)框")
end if
set fso = nothing
if (returnValue = "6" or returnValue = "0") then '覆蓋
stream.SaveToFile iLocal,2
MsgBox("文件備份成功!")
elseif (returnValue = "7") then
SaveFile
end if
end function
相關(guān)文章
windows.vbs.FSO.文件操作信息.磁盤驅(qū)動信息.文件夾操作信息全集
windows.vbs.FSO.文件操作信息.磁盤驅(qū)動信息.文件夾操作信息全集...2007-03-03
網(wǎng)絡(luò)接口利用率監(jiān)控VBS腳本代碼(Windows)
監(jiān)測windows主機(jī)網(wǎng)絡(luò)接口利用率的vbs代碼,需要的朋友可以參考下。2011-12-12
VBS教程:函數(shù)-StrReverse 函數(shù)
VBS教程:函數(shù)-StrReverse 函數(shù)...2006-11-11
vbs sendKeys Virtual-Key Codes 十六進(jìn)制符號
下表顯示了十六進(jìn)制符號常量名,,由系統(tǒng)所使用的虛擬鍵碼和鼠標(biāo)或鍵盤等值。這些代碼數(shù)字順序列出。2011-02-02
簡單用VBS調(diào)用企業(yè)微信機(jī)器人發(fā)定時消息的方法
這篇文章主要介紹了簡單用VBS調(diào)用企業(yè)微信機(jī)器人發(fā)定時消息的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
用vbs實現(xiàn)隨機(jī)讀取文件的一行內(nèi)容的腳本
用vbs實現(xiàn)隨機(jī)讀取文件的一行內(nèi)容的腳本...2007-10-10

