Re: VB.net code issue!
Could the service running as the OS admin not able to see my stored session I created on my windows admin user account??
Most probably. See https://winscp.net/eng/docs/faq_scheduler.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Could the service running as the OS admin not able to see my stored session I created on my windows admin user account??
Private Function winscpCaller() As Boolean
Dim winscp As Process = New Process()
Dim results As Boolean = False
Try
winscp.StartInfo.FileName = C:\FTPTEST\pushfiles_Script.bat"
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.RedirectStandardOutput = True
winscp.StartInfo.CreateNoWindow = True
winscp.Start()
' Wait until WinSCP finishes
winscp.WaitForExit(20000) '= 20seconds
' Success (0) or error?
If winscp.Has_Exited Then ' winscp.ExitCode <> 0 Then '(the forum blocks s E x)
results = True
Else
results = False
End If
Catch ex As Exception
WriteToErrorLog("error- " + ex.Message)
winscp.Kill()
winscp.Close()
winscp.Dispose()
Return False
Exit Function
Finally
If results = False Then
WriteToErrorLog("Process Killed")
winscp.Kill()
winscp.Close()
winscp.Dispose()
Else
WriteToErrorLog("Completed")
winscp.Close()
winscp.Dispose()
End If
End Try
Return results
End Function
Private Function winscpCaller(ByVal ProcessPathPlusName) As Boolean
Dim winscp As Process = New Process()
Dim results As Boolean = False
Try
' Run hidden WinSCP process
winscp.StartInfo.FileName = ProcessPathPlusName '= C:\FTPTEST\winscp422.exe (path + exe name)
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.CreateNoWindow = true
winscp.Start()
' Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch on")
winscp.StandardInput.WriteLine("option confirm off")
winscp.StandardInput.WriteLine("open OD")
winscp.StandardInput.WriteLine("put *")
winscp.StandardInput.WriteLine("close")
winscp.StandardInput.WriteLine("exit")
winscp.StandardInput.Close()
' Wait until WinSCP finishes
winscp.WaitForExit(20000) '= 20seconds max wait
' Success (0) or error?
If winscp.Has_Exited Then ' winscp.ExitCode <> 0 Then '(the forum blocks s E x)
results = True
WriteToErrorLog("process has exited normally")
Else
results = False
WriteToErrorLog("process has not exited normally")
End If
Catch ex As Exception
WriteToErrorLog("error- " + ex.Message)
winscp.Kill()
winscp.Close()
winscp.Dispose()
Return False
Exit Function
Finally
If results = False Then
WriteToErrorLog("Process Killed")
winscp.Kill()
winscp.Close()
winscp.Dispose()
Else
WriteToErrorLog("Completed")
winscp.Close()
winscp.Dispose()
End If
End Try
Return results
End Function
winscp.StartInfo.FileName = ProcessPathPlusName '= C:\FTPTEST\winscp422.exe (path + exe name)
winscp.StartInfo.Arguments = "/console /command " & _
Onecomma & "option batch on" & Onecomma & " " & _
Onecomma & "open OracleDataFeed" & Onecomma & " " & _
Onecomma & "put *" & Onecomma & " " & _
Onecomma & "exit" & Onecomma
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.CreateNoWindow = true
winscp.Start()