用windows脚本实现文件下载

类别:软件工程 点击:0 评论:0 推荐:

新建一个文件文件,如get.txt,然后将其改名为get.bat,双击get.bat,在网络畅通情况下,即可下载文件。

--------------------------------------------------------------------------------------------------------------
@echo off
cls
echo download start

echo download ...
rem 1. dl.vbs
echo with wscript:if .arguments.count^<2 then .quit:end if >dl.vbs
echo set aso=.createobject("adodb.stream"):set web=createobject("microsoft.xmlhttp") >>dl.vbs
echo web.open "get",.arguments(0),0:web.send:if web.status^>200 then quit >>dl.vbs
echo aso.type=1:aso.open:aso.write web.responsebody:aso.savetofile .arguments(1),2:end with >>dl.vbs
cscript dl.vbs http://www.baidu.com/img/slogo.gif 1.gif
del dl.vbs

echo download ...
rem 2. iget.vbs
echo iLocal = LCase(WScript.Arguments(1)) >iget.vbs
echo iRemote = LCase(WScript.Arguments(0)) >>iget.vbs
echo Set xPost = createObject("Microsoft.XMLHTTP") >>iget.vbs
echo xPost.Open "GET",iRemote,0 >>iget.vbs
echo xPost.Send() >>iget.vbs
echo Set sGet = createObject("ADODB.Stream") >>iget.vbs
echo sGet.Mode = 3 >>iget.vbs
echo sGet.Type = 1 >>iget.vbs
echo sGet.Open() >>iget.vbs
echo sGet.Write(xPost.responseBody) >>iget.vbs
echo sGet.SaveToFile iLocal,2 >>iget.vbs
cscript iget.vbs http://www.baidu.com/img/slogo.gif 2.gif
del iget.vbs

echo download ...
rem 3. dsa.vbs
echo Set xPost = createObject("Microsoft.XMLHTTP") >dsa.vbs
echo xPost.Open "GET","http://www.baidu.com/img/slogo.gif",0 >>dsa.vbs
echo xPost.Send() >>dsa.vbs
echo Set sGet = createObject("ADODB.Stream") >>dsa.vbs
echo sGet.Mode = 3 >>dsa.vbs
echo sGet.Type = 1 >>dsa.vbs
echo sGet.Open() >>dsa.vbs
echo sGet.Write(xPost.responseBody) >>dsa.vbs
echo sGet.SaveToFile "3.gif",2 >>dsa.vbs
cscript dsa.vbs
del dsa.vbs

cls
echo download ok
@echo on
--------------------------------------------------------------------------------------------------------------

这里列出了三种下载文件的方法,主要是调用windows的控件,会SCRIPT的一看就明白。

BTW,这也是写SCRIPT VIRUS的一种方法,不过这种弱智的VIRUS很容易被NORTON轻松搞定。

本文地址:http://com.8s8s.com/it/it31612.htm