I need a script that can be run on freshly installed windows xp+ and download specified files from internet, like http://www.python.org/ftp/python/2.6.2/python-2.6.2.msi Is it any easy way to do it without hand-crafting HTTP/FTP requests or using third-party programs like wget? I can suggest that WScript.CreateObject("internetexplorer.application") will do the magic, but documentation on it is extremely huge and Google is silent, as always :).
Just found this one pasted below. You can run it with cscript and have it scheduled.
VBScript is annoying unco-operative when it comes to doing things like this. This sort of thing always requires COM servers that aren't formally part of the scripting engine.
Maxwell's suggestion of using MSXML2.XMLHTTP seems a cool way round this. I must admit I hadn't come across that trick before. There are also various commercial COM servers that will do file downoads.
This type of problem is one of the reasons I'm looking at shifting much of my VBScript to Powershell. Because Powershell can seamless use .Net objects, doing such things is a lot easier.
JR
The method using
is more elegant, unfortunately is not very portable since the version of the object changes a lot throughout the versions and updates of Windows.
Using
is probably better but less elegant.
MSXML2.XMLHTTP is built around the old WinInet. There's a newer interface called Msxml2.ServerXMLHTTP, which is more reliable. It is built on a newer MS WinHTTP stack. I suggest calling WinHTTP directly.
Just use CreateObject("WinHttp.WinHttpRequest.5.1") instead of creating an MSXML2.XMLHTTP object. The rest of the code stays the same.