Pregunta:
Sin usar ninguna utilidad no estándar (incluida Windows), ¿es posible descargar usando la línea de comandos de Windows?
La versión preferida es Windows XP, pero también es interesante conocer las versiones más recientes.
Para aclarar aún más mi pregunta:
- Tiene que estar usando HTTP
- El archivo debe guardarse
- Instalación limpia estándar de Windows, sin herramientas adicionales
Básicamente, dado que todo el mundo está gritando Wget , quiero una funcionalidad Wget simple, sin usar Wget.
Respuesta:
Puede escribir un VBScript y ejecutarlo desde la línea de comando
Cree un archivo downloadfile.vbs
e inserte las siguientes líneas de código:
' Set your settings
strFileURL = "http://www.it1.net/images/it1_logo2.jpg"
strHDLocation = "c:\logo.jpg"
' 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
Ejecútelo desde la línea de comando de la siguiente manera:
cscript.exe downloadfile.vbs