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

Advertisement

srinukonatham
Joined:
Posts:
2
Location:
NJ

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

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()

Reply with quote

Advertisement

srinukonatham
Joined:
Posts:
2
Location:
NJ

Re: Winscp process hangs in vb.net code - Works in one system but not in other

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: https://winscp.net/eng/docs/guide_dotnet

Thanks in advance.

Reply with quote

Advertisement

You can post new topics in this forum