cmd下几种常见的下载文件的办法

好久没更新博客了 是时候来加快脚步成长了 接下来慢慢 会更新些笔记

win 03安装ftp服务

先在我虚拟机里把ftp安装好 win2003的 打开 控制面板-添加或删除程序-添加、删除组件–应用程序服务器(详细信息)–iis信息服务器(详细信息)–ftp 服务

1.ftp

ip:192.168.68.132

文件:test.txt

按顺序执行如下代码即可通过ftp来下载文件

cmd:

1
2
3
4
5
6
echo open 192.168.68.132 21> ftp.txt
echo ftp>> ftp.txt
echo bin >> ftp.txt
echo ftp>> ftp.txt
echo GET test.txt >> ftp.txt
ftp -s:ftp.txt

cmd下几种常见的下载文件的办法

2.vbs

vbs downloader,使用msxml2.xmlhttp和adodb.stream对象

如下代码保存为.vbs文件:

1
2
3
4
5
6
7
8
9
10
Set Post = CreateObject("Msxml2.XMLHTTP")
Set Shell = CreateObject("Wscript.Shell")
Post.Open "GET","http://192.168.68.132/test.txt",0
Post.Send()
Set aGet = CreateObject("ADODB.Stream")
aGet.Mode = 3
aGet.Type = 1
aGet.Open()
aGet.Write(Post.responseBody)
aGet.SaveToFile "C:\test\update\test.txt",2

对应到cmd下的命令为:

1
2
3
4
5
6
7
8
9
10
echo Set Post = CreateObject("Msxml2.XMLHTTP") >>download.vbs
echo Set Shell = CreateObject("Wscript.Shell") >>download.vbs
echo Post.Open "GET","http://192.168.68.132/test.txt",0 >>download.vbs
echo Post.Send() >>download.vbs
echo Set aGet = CreateObject("ADODB.Stream") >>download.vbs
echo aGet.Mode = 3 >>download.vbs
echo aGet.Type = 1 >>download.vbs
echo aGet.Open() >>download.vbs
echo aGet.Write(Post.responseBody) >>download.vbs
echo aGet.SaveToFile "C:\test\update\test.txt",2 >>download.vbs

3.powershell

cmd:

1
powershell (new-object System.Net.WebClient).DownloadFile('http://192.168.68.132/test.txt','C:\Users\isky\Downloads\test.txt')

4.bitsadmin

bitsadmin是一个命令行工具,可用于创建下载或上传工作和监测其进展情况。xp以后的Windows系统自带

使用方法:

cmd下:

1
bitsadmin /transfer n http://download.sysinternals.com/files/PSTools.zip C:\Users\isky\Downloads\PSTools.zip

cmd下几种常见的下载文件的办法

-------------本文结束感谢您的阅读-------------