Jump to content
Sign in to follow this  
sim6713

Help rewriting VBScript COM to AU3(CuteFTP)

Recommended Posts

sim6713

Hi,

I hope some one can show me how this VBScript code will look like in au3.

CODE

Dim Kirovsk

Dim oShell

Dim oAutoIt

Set oShell = CreateObject("Shell.Application")

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

Set Kirovsk = CreateObject("CuteFTPPro.TEConnection")

strHost = "172.26.120.190"

strPath = "/Borovica/Priorbank"

strLocalPath = "c:\Temp\test"

Kirovsk.Host = strHost

Kirovsk.Synchronize strPath, strLocalPath, 1, 0 'Synchronisation of folders (remote and local)

oAutoIt.ProcessWaitClose "ftpte.exe"

Share this post


Link to post
Share on other sites
sim6713

Manual of CuteFTP(Synchronizing folders with the TE)

Share this post


Link to post
Share on other sites
sim6713

Synchronizing folders with the TE

Description

Use the Synchronize method to perform one or two way mirrors of a remote and local folders contents.

Note:

The synchronize method contains as many as 9 parameters. Be sure to use absolute path names for both local and remote folder paths.

Syntax

Object.Synchronize(BSTR bstrRemoteName, BSTR bstrLocalName, long nDirection, long nAction, long nCasehandling, BOOL bRecursive, BOOL bIgnoreLinks, BOOL bDelDestination, BOOL bPromptDel);

Parameters

# Name Value

1 BstrRemoteName String value that specifies the absolute path name of the remote folder

2 BstrLocalName String value that specifies the absolute path name of the local folder

3 nDirection 0 = Mirror Local (make the remote look just like the local)

1 = Mirror Remote (make the local look just like the remote)

2 = Mirror Both

4 nAction When nDirection = 2 (Mirror Both)

0 = Mirror the more recent file

1 = Mirror the larger file

2 = Prompt for matching file names

3 = Skip mirroring files with the same names

-----------------------------------------------------------------

When nDirection = 0 or 1 (Mirror Local or Remote)

0 = Use Global Overwrite settings in the CuteFTP shell for matching filenames

1 = Always overwrite the file with a matching name

2 = Numerate the file (filename[1])

3 = Skip

5 nCaseHandling

0 = Transfer first and skip the rest (default)

1 = Show rename prompt

2 = Numerate

Note: This action applies when matching filenames are found and the only difference is the filename case.

6 bRecursive

0 = Don't sync subfolders

1 = Apply sync to subfolders (default)

7 bIgnoreLinks

0 = Don't ignore symbolic links

1 = Ignore symbolic links (default)

8 bDelDestination

0 = Don't remove destination

1 = Remove destination if source does not exist (default)

Note: This action only applies to one-way mirroring. If a file exists in the destination that isnt in the source being mirrored, then delete the destination file.

9 bPromptDel

0 = Don't prompt before removing destination

1 = Prompt before removing destination (default)

Note: Only applies to one-way mirroring when DelDestination is True.

Examples

'Simple synchronize using minimal parameters

Set MySite = CreateObject("CuteFTPPro.TEConnection")

Dont forget to initialize all necessary fields for MySite : host name, user, password, etc.

MySite.Connect

MySite.Synchronize "/pub/myfolder", "C:\mysitesfiles", 0, 1

'This will perform a local mirror, overwriting any matching filename.

'Simple synchronize using minimal parameters

Set MySite = CreateObject("CuteFTPPro.TEConnection")

Dont forget to initialize all necessary fields for MySite : host name, user, password, etc.

MySite.Connect

MySite.Synchronize "/pub/myfolder", "C:\mysitesfiles", 2, 0

'This will perform full mirror (both), overwriting older files when a matching filename is found.

'Slightly more complex synchronize routine used to synchronize bookmarks. Uses variables for the path names

strRemotePath = "\Favorites"

strLocalPath = "C:\Documents and Settings\username\Favorites"

Dont forget to initialize all necessary fields for MySite : host name, user, password, etc.

MySite.Connect

If (Not (MySite.IsConnected)) Then

MsgBox "Unable to connect to server:" + MySite.Host

End if

MySite.Synchronize strRemotePath, strLocalPath, 2, 3, 0, 1, 1, 0, 1

'Performs a full mirror, skips matching filenames, transfers only the first file if multiple files are found with the same name but different case, applies to subfolders, ignores symbolic links, does not remove destination files if the source doesn't exist (N/A when dealing with dual mirror), and prompt prior to deleting anything (N/A when dealing with dual mirror).

MsgBox "DONE!" Alert me to the completed task

MySite.Disconnect Disconnects from the site when done

MySite.Close Close the Transfer Engine process

A full synchronizaiton VB subroutine:

Sub Sync()

Dim MySite

Set MySite = CreateObject("CuteFTPPro.TEConnection")

strHost = "ftp.yourhost.com"

strPath = "/pub"

strLocalPath = "c:\temp\sync_test"

strHost = InputBox("Enter host", "CuteFTP Pro", strHost)

strPath = InputBox("Enter remote path", "CuteFTP Pro", strPath)

strLocalPath = InputBox("Enter local path", "CuteFTP Pro", strLocalPath)

MySite.Host = strHost

MySite.CaseHandling = 1

MySite.Recursive = False

MySite.IgnoreLinks = True

MySite.DeleteDestination = False

MySite.PromptDelete = True

nUserChoise = MsgBox ("Mirror remote: " & strHost & strPath & " to local " & strLocalPath & " ?", vbYesNoCancel)

If nUserChoise = vbYes Then

MySite.Synchronize strPath, strLocalPath, 1, 0

else

nUserChoise = MsgBox ("Mirror local: " & strHost & strLocalPath & " to remote " & strPath & " ?", vbYesNoCancel)

If nUserChoise = vbYes Then

MySite.Synchronize strPath, strLocalPath, 0, 0

else

nUserChoise = MsgBox ("Mirror both: " & strHost & strPath & " <- > " & strLocalPath & " ?", vbYesNoCancel)

If nUserChoise = vbYes Then

MySite.Synchronize strPath, strLocalPath, 2, 1

else

End if

End if

End if

End Sub

Synchronizing_folders_with_the_TE.doc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×