Topic "Winscp process hangs in vb.net code - Works in one system but not in other"

Author Message
srinukonatham
[View user's profile]

Joined: 2012-02-15
Posts: 2
Location: NJ
Hello,
We have been using 5.0.7 for quite a long time and no issue, recently the system got replaced and the program hangs at StandardOutput.ReadToEnd() command.
We are using this as a process to call winscp.com inside a vb.net function with saved session. saved sessions are stored in .ini file.

While we are in debug mode it's working fine, but when we try to run it under a service using "Local System" account, it hangs.
Any help would be much appreciated.

Here is the code that i am using
winscp = New Process()
winscp.StartInfo.FileName = "E:\Tools\WinSCP506\WinSCP.com

winscp.StartInfo.Arguments = String.Format("/log=""{0}""", "e:\logs\a.txt")
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.RedirectStandardOutput = True
winscp.StartInfo.CreateNoWindow = True

AddHandler winscp.OutputDataReceived, AddressOf LogMessageHandler
AddHandler winscp.ErrorDataReceived, AddressOf ErrorMessageHandler
winscp.Start()
winscp.StandardInput.WriteLine("option batch abort")
winscp.StandardInput.WriteLine("option confirm off")
winscp.StandardInput.WriteLine(String.Format("open mysavedsession "))
winscp.StandardInput.WriteLine("cd /somefolder")
winscp.StandardInput.WriteLine("put " & ControlChars.Quote & localPackagePath & ControlChars.Quote & " " & ControlChars.Quote & encryptedFileName & ControlChars.Quote)
winscp.StandardInput.Close()
'**********This is where the program hangs
Dim output As String = winscp.StandardOutput.ReadToEnd()
'***********If i comment the above line then it hangs here.
winscp.WaitForExit()
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
Is there anything in the e:\logs\a.txt?

My wild guess is that on the new system you do not have a host key accepted:
http://winscp.net/eng/docs/scripting#hostkey

Btw, you should better use WinSCP .NET assembly:
http://winscp.net/eng/docs/library
srinukonatham
[View user's profile]

Joined: 2012-02-15
Posts: 2
Location: NJ
Prikyl,
Thank you for your quick response.
Log file was not created.
I have installed the winscp and accepted the host key for that server, still the same issue.
For testing purposes I have created a simple command line application in vb using the same method and it's working fine but when I call the same method as part of Windows Service application, it's not working. Windows service is running as "Local System" account.
In fact it's logging in to server from command prompt.

Planning to use .net assembly going forward, but the existing application were effected by this. Any assistance would be much appreciated.
Just wanted to mention that the code i am using was copied from the link: http://winscp.net/eng/docs/guide_dotnet

Thanks in advance.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
What do you get in output?
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