Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Could it possible to Copy Files From http://.. using VBScript

Status
Not open for further replies.

larryjr

Technical User
Aug 27, 2001
20
0
0
JP
I need help to write VBScript copying files from web like;

Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile " _
"c:\MYDOCU~1\"

Could it possible ?
Initially \\servername\dirA/subdir/filename worked, but
I would like to use this for copying files even server
name and directories are unknown.
 
Just a gues but you may want to try Server.MapPath("/")
It will give you the "real" path that the server is on then you can concantinate it with the rest of your relative path.....it has been a while since I have so you may want to hit MSDN to get the specifics of the command


Tal McMahon
 
To Tal McMahon

Thanks for your response.I appreciate your comments
for using serverpath"/"
Am I understanding you mean ?;

<HTML><HEAD></HEAD>
<BODY>
<script language=&quot;VBScript&quot;>
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
fso.CopyFile &quot;/TESTBook.xls&quot;, &quot;c:\MYDOCU~1\&quot;
Set WShshell= Nothing
</script>
</BODY></HTML>

The TESTBook.xls is placed in the same server directory
where the web page is placed.
But opening this web page still failes to copy the file.

I really like to write the script as follows;

<HTML><BODY>
<script language=&quot;VBScript&quot;>
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
fso.CopyFile &quot; _
&quot;c:\MYDOCU~1\&quot;
Set WShshell= Nothing
</script>
</BODY></HTML>

Is this possible ?

In the LAN, it's easy to know the servername and I can
write the line like
fso.CopyFile &quot;\\myserver\DirXX\TESBook.xls&quot;
In case that I am on ISP with PPP,
is there any measure to use the line like
&quot;\\servername\mydir\subdir\TESTBook.xls&quot;
,getting the real name of the server?

LarryJR Hobbs
 

larryjr,

I don't beleieve this is possible because you are using two different network protocols that don't speak to each other.
You might want to try downloading the file first to a local disk and then copy the file.


fengshui_1998
 
Hi All,

Squeezing out my brain for couple of days and asking friends
of mine,I gave up original method and seeked new one;

&quot;XMLHTTP&quot;.

Here presenting with bloodshot eyes.
Many thanks to Eric.

I need further help from all for I am still getting the
problem with copying *.gif using this. Thanks in advance.

<SCRIPT LANGUAGE=&quot;VBScript>
'--Begin user variables--
sSource = _
&quot;sDest = &quot;c:\MYDOCU~1\testCopy.js&quot;
'---End user variables---

set myXML = WScript.CreateObject(&quot;Microsoft.XMLHTTP&quot;)
set fso = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;)

myXML.open &quot;GET&quot;, sSource, False
myXML.send
targetbody = myXML.responseBody
set myXML = nothing

sOut = &quot;&quot;
For i = 0 to UBound(targetbody)
sOut = sOut & _
chrw(ascw(chr(ascb(midb(targetbody,i+1,1)))))
Next

set mycopy = fso.CreateTextFile(sDest, True)
mycopy.Write sOut
mycopy.Close
set mycopy = Nothing
set fso = Nothing
WScript.Echo &quot;Done!&quot;
</SCRIPT>

LarryJR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top