Free Power Tools Brochure
Get Mark Minasi's
17-page guide today!



      

advertisement

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

July 27, 2004 10:27 PM

JSI Tip 8297. Anonymous FTP download script.

Rating: (0)
Windows IT Pro
InstantDoc ID #81417


Borrowing from http://www.paulsadowski.com/WSH/getremotebinaryfile.htm, I have scripted FTPVBS.BAT and FTPVBS.VBS to download a binary, or text file, using FTP.

The syntax for using FTPVBS.BAT is:

call FTPVBS URL Folder FileName [OK]

Where URL is the URL of the file you wish to download, Folder is the destination folder where you will store the downloaded file, and FileName is the file name to be stored in Folder.

NOTE: OK is an optional fourth parameter, a call directed environment variable, that will contain a Y if FileName was downloaded, and an N if it was not.

NOTE: FTPVBS.BAT and FTPVBS.VBS must be located in the same folder.

FTPVBS.BAT contains:

@echo off
setlocal
if {%3}

{} goto err set URL=%1 set fldr=%2# set file=%3 set fldr=%fldr:"=% set fldr=%fldr:\#=% set fldr="%fldr:#=%\" set file="%file:"=%" set ff=%fldr%%file% set ff="%ff:"=%" if exist %ff% del /q %ff% set ftpv="%~DP0FTPVBS.vbs" cscript //NOLOGO %ftpv% %URL% %fldr% %file% if {%4}

{} endlocal&goto :EOF set found=N if exist %ff% set found=Y endlocal&set %4=%found% goto :EOF :err @echo Syntax: FTPVBS URL Folder FileName [OK] endlocal
FTPVBS.VBS contains:
Dim objArgument
Set objArgument = Wscript.Arguments
URL=objArgument(0)
DestFolder=objArgument(1)
ImageFile=objArgument(2)
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False, "user", "pass"
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



ARTICLE TOOLS

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

VB Script to enable user account

Do any of you guys have a VB script that could be used to enable a AD user account? We are setting up a "firecall" ID which will stay disabled until i...222-96219

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

Podcasts

To successfully implement virtual desktops, IT administrators must carefully match user requirements to specific desktop technologies. Listen to this podcast to learn what you need to keep in mind when formulating your approach to desktop virtualization.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

Aside from its employees, data is an organization’s most important resource. Join Windows technical specialist and 11-time MVP John Savill to learn the best practices for managing data using features in Windows Server.
View this web seminar on demand!

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.