Simple VBScript Problem

Discussion in 'OT Technology' started by doggfather, Feb 9, 2006.

  1. doggfather

    doggfather New Member

    Joined:
    Aug 6, 2005
    Messages:
    224
    Likes Received:
    0
    <script type="text/vbscript">
    object.GetFile(x.txt)

    </script>

    I have a "x.txt" file and I want to have the browser download that file from my server lets say http://localhost/x.txt into C:\x.txt

    How can I do this?
     
  2. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    Sorry, it would be a lot tricker than that.

    I assume your trying to get a script to copy a file from a webserver to a local drive.

    Does it have to be done from within a webpage? is this for internet or intranet?

    Personally I'd look at making a simple app or even a batchfile if its an intranet. Doing that within IE would probably throw a lot of cautions etc.
     
  3. doggfather

    doggfather New Member

    Joined:
    Aug 6, 2005
    Messages:
    224
    Likes Received:
    0
    Here's my goal, I want to write an application that downloads 1.jpg, 2.jpg, etc...99.jpg off a web server, and download it to my local drive C:\
     
  4. blang

    blang lang

    Joined:
    Jun 25, 2004
    Messages:
    1,956
    Likes Received:
    0
    Location:
    cambodia
    to get around the security restrictions, you'd probably need an activex control or seomthing. never done it though.

    I'd recommend just using "file > save page as" in firefox. it will save you oodles of time. Or get FTP access to the webservers
     
  5. doggfather

    doggfather New Member

    Joined:
    Aug 6, 2005
    Messages:
    224
    Likes Received:
    0
    im not saving any images--its a project for school
     
  6. Yep

    Yep Knick knack paddy whack, give the old dog a bone

    Joined:
    Jan 22, 2001
    Messages:
    4,603
    Likes Received:
    0
    Location:
    South Jersey
    I don't know of an easy way to do this in VScript, though I'd be open to it. I was working on doing something like this and ended up scrapping the idea because it was easier to write a small VB program to do it for me than spend the time researching it.
     
  7. EvilSS

    EvilSS New Member

    Joined:
    Jun 11, 2003
    Messages:
    5,104
    Likes Received:
    0
    Location:
    STL
    Google ftw : http://www.codecomments.com/archive299-2005-12-733582.html

    Code:
    MsgBox GetSource("http://servername/path/filename.csv", _
    CreateObject("WScript.Shell").CurrentDirectory & =
    "\myfilename.csv")
     
    Function GetSource(source, target)
     
    With CreateObject("MSXML2.XMLHTTP")
    .open "GET", source, False
    .send
    sText =3D .responseText
    End With
     
    With CreateObject("Scripting.FileSystemObject").OpenTextFile(target, =
    2, True)
    .Write sText
    .Close
    End With
     
    GetSource =3D source & vbcrlf & vbcrlf & " saved as:" & vbcrlf & =
    vbcrlf & target
     
    End Function
    
    edit: I don't think those "3D"'s belong in there.
     

Share This Page