Topic "no output with VB2010"

Author Message
PitWi
[View user's profile]

Joined: 2013-02-08
Posts: 2
Location: Vienna
My code in VB 2010:

Code:

        Dim proc As Process = New Process
        Dim prot As String = ""
        proc.StartInfo.FileName = prg  ' refers to WinSCP programfile
        proc.StartInfo.Arguments = "/console /command /log=C:\Users\pw\Desktop\log.txt"
        proc.StartInfo.UseShellExecute = False
        proc.StartInfo.RedirectStandardInput = True
        proc.StartInfo.RedirectStandardOutput = True
        proc.StartInfo.RedirectStandardError = True
        proc.StartInfo.CreateNoWindow = True
        Try
            proc.Start()
        Catch ex As Exception
            proc.Close()
            proc.Dispose()
            Beep()
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
        proc.StandardInput.WriteLine("option batch abort")
        proc.StandardInput.WriteLine("option confirm off")
        proc.StandardInput.WriteLine("open uid:pwd@mama.uni.ac.at")
        proc.StandardInput.WriteLine("ls")
        proc.StandardInput.Close()
        prot = proc.StandardOutput.ReadToEnd()
        proc.WaitForExit()
        If proc.ExitCode <> 0 Then
            proc.Close()
            proc.Dispose()
            Beep()
            MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If
        proc.Close()
        proc.Dispose()
        MsgBox(prot)


What I want is a list of the files and directories on the server. I tried several variationes but "prot" is always empty and log.txt isn't created. Why? A similar app with upload of files works great.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Please use WinSCP .NET assembly:
https://winscp.net/eng/docs/library
PitWi
[View user's profile]

Joined: 2013-02-08
Posts: 2
Location: Vienna
prikryl wrote:
Please use WinSCP .NET assembly:
https://winscp.net/eng/docs/library


Thanks.
I did it before and it works but I'm not sure if that's the answer I wanted because WinSCP .NET is really nice but it complicates the setup of my application.
Advertisements

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License