Option batch abort - and command window still stays on scree

Advertisement

JonWayn
Joined:
Posts:
3
Location:
Bellingham, WA

Option batch abort - and command window still stays on scree

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\winscp.com"""


Const Url = "someurl.com"
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
WScript.Sleep(1000)
'WScript.Echo(Exec.StdOut.ReadAll())
Loop


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

Set LogFile = FSO.GetFile(LogFilePath)

If LogFile Is Nothing Then
WScript.Echo "Cannot locate log file"
WScript.Quit(1)
End If

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,468
Location:
Prague, Czechia

Re: Option batch abort - and command window still stays on scree

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.

Reply with quote

Advertisement

You can post new topics in this forum