[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1243
  • Last Modified:

URGENT - CreateObject("ADODB.Stream") errors on Windows XP with SP2

I was using the following client side script to download a file onto a client pc with Windows XP Pro SP1

<HTML>
<HEAD>
<script language=VBScript >
'===============================================================
' Example using ADODB Stream Object to load resource from server
' and deposit in specified directory on client, using client-side
' script
' Peter Bromberg
'================================================================
' Don't need the TypeLib METADATA at the top if you specify the constants by numeric value instead of by name

' Set up an ADO Stream ....
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1 ' adTypeBinary
' The following should be the absolute URL to the file on the server.....
objStream.Open ("URL=http://myservername/virtualdirname/test.doc")
document.write "<CENTER>Loaded...<BR>"
' This should be the full path and filename to save the file on the client....
objStream.SaveToFile "C:\test.doc", 2 ' adSaveCreateOverWrite
document.write "saved..<BR>"
objStream.Close
Set objStream = Nothing

</script>
<TITLE>Download and Install Page</TITLE>
</HEAD>
<BODY>
DONE!</CENTER>
</BODY>
</HTML>


After installing SP2, I am getting an error "Safety settings on this computer prohibit accessing a data source on another domain."  I am calling the page from http://myservername/virtualdirname/getfile.htm  Why does the error indicate that I am accessing another domain?  The code works fine on Windows 2000.  Where is this safety setting?  How can I configure it?
0
sndip
Asked:
sndip
  • 3
  • 2
1 Solution
 
jmelikaCommented:
This is no longer possible with XP SP2.  It's considered a bug in IE and Windows so it's automatically disabled.

Consider using a different method in your script.  Have you thought of using ServerXMLHTTP?

      Dim objSvrHTTP
      Dim PostData
      
      Set objSvrHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
      objSvrHTTP.open "GET", "http://myservername/virtualdirname/test.doc", false

      objSvrHTTP.send
      Response.Write objSvrHTTP.responseText
0
 
sndipAuthor Commented:
Thanks for the info on SP2.  What is the requirements for using Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")?  Can you give me the sample code on the client to write the file to their harddrive?
0
 
jmelikaCommented:
It's really simple.  The sample code I gave you will do.  If you need further help with the object, you might want to do a google search for the Msxml2.ServerXMLHTTP.4.0

Here is a page that explains some of it.

http://www.eggheadcafe.com/ng/microsoft.public.inetserver.dbweb/post2131077.asp
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mk_bCommented:
Im running xpPro  sp2 and i changes your and this is working for me give it a shot

<HTML>
<HEAD>
<%
'===============================================================
' Example using ADODB Stream Object to load resource from server
' and deposit in specified directory on client, using client-side
' script
' Peter Bromberg
'================================================================
' Don't need the TypeLib METADATA at the top if you specify the constants by numeric value instead of by name

' Set up an ADO Stream ....
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1 ' adTypeBinary
' The following should be the absolute URL to the file on the server.....
objStream.Open ("URL=http://markb/_002.doc")
response.Write "<CENTER>Loaded...<BR>"
' This should be the full path and filename to save the file on the client....
objStream.SaveToFile "C:\test.doc", 2 ' adSaveCreateOverWrite
response.write "saved..<BR>"
objStream.Close
Set objStream = Nothing
%>

<TITLE>Download and Install Page</TITLE>
</HEAD>
<BODY>
DONE!</CENTER>
</BODY>
</HTML>
0
 
sndipAuthor Commented:
mk_b, you changed it from client vbscript to server side script.  I need the file to be saved on the client's harddrive.  How do I save the file to the client's harddrive after using objStream.Open on the server?
0
 
jmelikaCommented:
Try this code:

'GetRemoteBinaryFile.vbs

ImageFile = "file.doc"
DestFolder = "C:\"
URL = "http://www.site.com/file.doc"

Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False
xml.Send

set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1

oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody

' Do not overwrite an existing file
oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist

' Use this form to overwrite a file if it already exists
' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite

oStream.close

set oStream = nothing
Set xml = Nothing

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now