Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I wrote this script to connect to a FTP using a proxy server. You could adapt it for your needs. It prompts for the filename and folder you are trying to access. Just cut the code you don't need, and you should be good to go.</p> <p>You will need to change the FTP Server Name variable as well. Happy coding:</p> <pre><code>Option Explicit Dim objShell, strFTPScriptFileName, strFile2Get Dim strLocalFolderName, strFTPServerName, strLoginID Dim strPassword, strFTPServerFolder, strFileToGet, returnCode 'Customize code here to fit your needs strFTPServerName = "proxy.prv" strLocalFolderName = "" strLoginID = "" strPassword = "" strFTPServerFolder = "" strFileToGet = "" strLocalFolderName = GetLocalFolder() strLoginID = InputBox("Enter FTP Username: ", "Enter FTP Username", "Authentication_Method@Destination_FTP_Host") strPassword = InputBox("Enter FTP Password: ", "Enter FTP Password", "Authentication_Method@Destination_FTP_Host") strFTPServerFolder = InputBox("Enter FTP folder that you want to access: ", "Enter FTP Folder", "/") strFileToGet = InputBox("Enter the filename located on the FTP that you want to retrieve: ", "Enter FTP file", "*.*") if strLoginID = "" then WScript.Echo "You must specify a Login ID for this script to work" WScript.Quit() end if if strPassword = "" then WScript.Echo "You must specify a Password for this script to work" WScript.Quit() end if if strFTPServerFolder = "" then WScript.Echo "You must specify a FTP Folder to access for this script to work" WScript.Quit() end if if strFileToGet = "" then WScript.Echo "You must specify a Filename to download for this script to work" WScript.Quit() end if Call WriteFTPScript() Set objShell = WScript.CreateObject( "WScript.Shell" ) returnCode = objShell.Run( "cmd.exe /c ftp -s:" &amp; chr(34) &amp; strFTPScriptFileName &amp; chr(34), 1, true) if (returnCode = 0) then Wscript.echo("Your file has been downloaded.") else Wscript.echo("An error has occured while attempting to download your file.") End if objShell.Run (strLocalFolderName) Set objShell = Nothing ' ************************************************************************** ' Creates the FTP script text file Function WriteFTPScript() Dim objFSO, objMyFile strFTPScriptFileName = strLocalFolderName &amp; "\FTPScript.txt" 'File to be created to hold ftp script data Set objFSO = CreateObject("Scripting.FileSystemObject") If (objFSO.FileExists(strFTPScriptFileName)) Then objFSO.DeleteFile (strFTPScriptFileName) End If Set objMyFile = objFSO.CreateTextFile(strFTPScriptFileName, True) objMyFile.WriteLine ("open " &amp; strFTPServerName) objMyFile.WriteLine (strLoginID) objMyFile.WriteLine (strPassword) objMyFile.WriteLine ("cd " &amp; strFTPServerFolder) objMyFile.WriteLine ("lcd " &amp; strLocalFolderName) objMyFile.WriteLine ("get " &amp; strFileToGet) objMyFile.WriteLine ("bye") objMyFile.Close Set objFSO = Nothing Set objMyFile = Nothing End Function ' ************************************************************************** ' Dialog box to select folder to download to Function GetLocalFolder() Const BIF_returnonlyfsdirs = &amp;H0001 Const BIF_editbox = &amp;H0010 Dim wsh, objDlg, objF Set objDlg = WScript.CreateObject("Shell.Application") Set objF = objDlg.BrowseForFolder (&amp;H0, "Select the destination folder to download FTP files to:", BIF_editbox + BIF_returnonlyfsdirs) If IsValue(objF) Then GetLocalFolder = objF.ParentFolder.ParseName(objF.Title).Path Else WScript.Echo "You MUST specify a folder to download files to. Application will now exit." WScript.Quit End If end function ' ************************************************************************** ' Verifies if the the object contains a value Function IsValue(obj) Dim tmp On Error Resume Next tmp = " " &amp; obj If Err &lt;&gt; 0 Then IsValue = False Else IsValue = True End If On Error GoTo 0 End Function ' ************************************************************************** ' Verifies if the the object is a folder Function IsFolder(obj) Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") if objFSO.IsFolder(obj) then IsFolder = True end if End Function </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload