I am trying to write a VBScript that will download some files to the local machine.
So far I have this:
Dim WSHShell, WSHNetwork, objFSO, IEObject, objXMLHTTP, objADOStream
Set WSHShell = CreateObject("WScript.Shel
l")
Set WSHNetwork = CreateObject("WScript.Netw
ork")
Set objFSO = CreateObject("Scripting.Fi
leSystemOb
ject")
Set IEObject = CreateObject("InternetExpl
orer.Appli
cation")
Set objXMLHTTP = CreateObject("MSXML2.XMLHT
TP")
Set objADOStream = CreateObject("ADODB.Stream
")
If (objFSO.FolderExists("C:\B
uild-Temp\
") = False) Then
objFSO.CreateFolder "C:\Build-Temp\"
End If
Dim localSource
Set localSource = objFSO.GetFolder("C:\Build
-Temp\")
' Download needed files
Dim downloadServer, buildFiles, i
downloadServer = "
http://SERVERIP/DIRECTORY/"
buildFiles = array("file1.msi","file2.z
ip","file3
.exe")
For i = 0 To UBound(buildFiles)
GetBinaryFile localSource.Path & "\" & buildFiles(i), localSource & "\" & buildFiles(i)
Next
Sub GetBinaryFile (strURL, strDest)
objXMLHTTP.Open "GET", strURL, false
objXMLHTTP.Send()
If objXMLHTTP.Status = 200 Then
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
If objFSO.FileExists(strDest)
Then
objFSO.DeleteFile strDest, ForceIt
End If
objADOStream.SaveToFile strDest
objADOStream.Close
End if
End Sub
The file is there and exists but I always get an error on the line that reads: objXMLHTTP.Send()'
The system can not locate the resource specified.
It is Windows 2003 and IE 7 is installed. The server it is fetching from is on a different subnet than the client but it does have HTTP and HTTPS access to this server. I can see the file when I go to it manually in IE. It is not in my trusted zones and I think that is the cause of the problem.
Now for the hard part, how do I add it to the trusted zones so that it applies to the whole computer?
I've been through this doc:
http://support.microsoft.com/kb/182569 but it doesn't seem to be working.
Let's say they are files from MS. I add these keys:
MACHINE\Software\Policies\
Microsoft\
Windows\Cu
rrentVersi
on\Interne
t Settings\Security_HKLM_onl
y=4,1
MACHINE\Software\Policies\
Microsoft\
Windows\Cu
rrentVersi
on\Interne
t Settings\Security_options_
edit=4,1
MACHINE\Software\Policies\
Microsoft\
Windows\Cu
rrentVersi
on\Interne
t Settings\Security_zones_ma
p_edit=4,1
MACHINE\Software\Microsoft
\Windows\C
urrentVers
ion\Intern
et Settings\ZoneMap\Domains\l
ive.com\*=
4,2
MACHINE\Software\Microsoft
\Windows\C
urrentVers
ion\Intern
et Settings\ZoneMap\Domains\m
icrosoft.c
om\*=4,2
MACHINE\Software\Microsoft
\Windows\C
urrentVers
ion\Intern
et Settings\ZoneMap\Domains\m
sn.com\*=4
,2
MACHINE\Software\Microsoft
\Windows\C
urrentVers
ion\Intern
et Settings\ZoneMap\Domains\p
assport.ne
t\*=4,2
MACHINE\Software\Microsoft
\Windows\C
urrentVers
ion\Intern
et Settings\ZoneMap\Domains\w
indowsupda
te.com\*=4
,2
This is from a security template file. I copied these keys from a profile that had all of these as trusted sites and then moved them to HKLM as the KB article said to. They don't even show on the list when I look though. The *=4,2 means that '*' is the name of the key, '4' is the data type which in this case is DWORD, and '2' is the numerical value for the key.
When I browse to the file manually I do get the security warning saying I can't download from this site because it isn't trusted so I can verify that. If you have any solutions and/or alternate methods to fetch these files I would appreciate it. I don't want to have to install extra apps, so wget and curl and the like are out.
Start Free Trial