Differences
This shows you the differences between the selected revisions of the page.
| 2012-03-09 | 2012-03-20 | ||
| using object initializer c# (martin) | option explicit, rm debug code (martin) | ||
| Line 307: | Line 307: | ||
| <reference object="WinSCP.Session"/> | <reference object="WinSCP.Session"/> | ||
| <script language="VBScript"> | <script language="VBScript"> | ||
| + | |||
| + | Option Explicit | ||
| ' Setup session options | ' Setup session options | ||
| + | Dim sessionOptions | ||
| Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions") | Set sessionOptions = WScript.CreateObject("WinSCP.SessionOptions") | ||
| - | sessionOptions.Protocol = Protocol_Sftp | + | With sessionOptions |
| - | sessionOptions.HostName = "example.com" | + | ····.Protocol = Protocol_Sftp |
| - | sessionOptions.UserName = "user" | + | ····.HostName = "example.com" |
| - | sessionOptions.Password = "mypassword" | + | ····.UserName = "user" |
| - | sessionOptions.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | ····.Password = "mypassword" |
| - | + | ····.SshHostKey = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | |
| + | End With | ||
| + | |||
| + | Dim session | ||
| Set session = WScript.CreateObject("WinSCP.Session") | Set session = WScript.CreateObject("WinSCP.Session") | ||
| - | |||
| - | session.DebugLogPath = "debug.log" | ||
| - | session.DisableVersionCheck = True | ||
| ' Connect | ' Connect | ||
| session.Open sessionOptions | session.Open sessionOptions | ||
| + | Dim today, stamp | ||
| today = Date | today = Date | ||
| stamp = Year(today) | stamp = Year(today) | ||
| Line 335: | Line 339: | ||
| stamp = stamp & Day(today) | stamp = stamp & Day(today) | ||
| + | Dim fileName, remotePath, localPath | ||
| fileName = "export_" & stamp & ".txt" | fileName = "export_" & stamp & ".txt" | ||
| remotePath = "/home/user/sysbatch/" & fileName | remotePath = "/home/user/sysbatch/" & fileName | ||
| localPath = "d:\backup\" & fileName | localPath = "d:\backup\" & fileName | ||
| + | Dim fs | ||
| Set fs = WScript.CreateObject("Scripting.FileSystemObject") | Set fs = WScript.CreateObject("Scripting.FileSystemObject") | ||
| Line 344: | Line 350: | ||
| ' You can achieve the same using: | ' You can achieve the same using: | ||
| + | ' Dim transferOptions | ||
| ' Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions") | ' Set transferOptions = WScript.CreateObject("WinSCP.TransferOptions") | ||
| ' transferOptions.IncludeMask = fileName | ' transferOptions.IncludeMask = fileName | ||
| Line 349: | Line 356: | ||
| ' SynchronizationMode_Local, localPath, remotePath, false, false, SynchronizationCriteria_Time, _ | ' SynchronizationMode_Local, localPath, remotePath, false, false, SynchronizationCriteria_Time, _ | ||
| ' transferOptions).Check | ' transferOptions).Check | ||
| + | |||
| + | Dim download, remoteWriteTime, localWriteTime | ||
| + | |||
| If session.FileExists(remotePath) Then | If session.FileExists(remotePath) Then | ||
| If Not fs.FileExists(localPath) Then | If Not fs.FileExists(localPath) Then | ||