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