Topic "Option batch abort - and command window still stays on scree"

Author Message
[View user's profile]

Joined: 2012-06-22
Posts: 3
Location: Bellingham, WA
I am trying to use vbscript to get a file listing from an sftp site through WinScp. However, the command window, once open, stays on the screen and nothing happens until after I close it manually, then WinScp returns error -1073741510 (which translate to 'the user terminated the session). Here is the first part of my code:

Option Explicit
DIM FSO, Shell, Exec, LogFile
Dim LocalPath, RemotePath, FileMask, LogFilepath, NL

Const AppPath = """C:\Program Files (x86)\WinScp\"""

Const Url = ""
Const Login = "somelogin"
Const Pwd = "somepassword"

LocalPath = "C:\Working\Access\Temp\"
LogFilePath = LocalPath & "LogFile.xml" 'Can this be a txt file???
RemotePath = "/home/user/archive/" 'Do I leave this blank for the root folder???
FileMask = "*.txt"

Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set Shell = WScript.CreateObject("WScript.Shell")
Set Exec = Shell.Exec(AppPath & " /log=""" & LogFilePath & """") 'isnt this line supposed to create a file? It does not

Exec.StdIn.Write( _
"option batch abort\n" _
& "open " & Login & ":" & Pwd & "@" & Url & "\n" _
& "ls """ & RemotePath & FileMask & """\n" _
& "exit\n") 'After this line, isnt the command window supposed to go away? it doesnt. I have to close it manually

Do While Exec.Status = 0

If Exec.ExitCode <> 0 Then
WScript.Echo "Error retrieving file listing", Exec.ExitCode
End If

Set LogFile = FSO.GetFile(LogFilePath)

If LogFile Is Nothing Then
WScript.Echo "Cannot locate log file"
End If
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26299
Location: Prague, Czechia
Thanks for your report.
I have sent you an email with a debug version of WinSCP to address you have used to register on this forum.
Martin Prikryl

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License