Hi,
please see the description of the problem:
Env: WinSCP Version 5.7.7 (Build 6257) (OS 6.0.6002 Service Pack 2 - Windows Server (R) 2008 Standard)
We use an ETL tool - Informatica Power Center to automate file transfers, where ftp/sftp operations are handled by WinSCP.
The workflow is as follows:
1. Informatica generates .bat file which includes WinSCP command
2. Informatica executes the .bat file
Everything works fine, except the situation where we start parallel WinSCP instances. Results of WinSCP execution are correct, files are transferred, but something bad happens in the environment - any .bat files that are started by cmd.exe which is a child of pmserver.exe(Informatica agent) simply don't execute any operations. To resolve this problem we have to restart the process pmserver.exe. Meanwhile, the same .bat files are executed always correctly from my console.
The bat files that are started in parallel look as follows (I put simplified version for clarity):
bat1.bat
WinSCP /console /script=D:\script1 /loglevel=0 /log=D:\script1.log > D:\bat1.log 2>>&1
if %ERRORLEVEL% neq 0 goto error
del D:\script1
exit
:error
exit 1
script1
option batch abort
option confirm off
open sftp://user:password@hostname1 -hostkey="ssh-rsa 2048 *:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*:*"
put D:\filename* /test/newfilename
exit
bat2.bat
WinSCP /console /script=D:\script2 /loglevel=0 /log=D:\script2.log > D:\bat2.log 2>>&1
if %ERRORLEVEL% neq 0 goto error
del D:\script2
exit
:error
exit 1
script2
option batch abort
option confirm off
open ftp://user:password@hostname2
put D:\filename* /test/filename
exit
Last lines of logs generated by WinSCP:
script1.log:
. 2016-05-18 13:59:06.646 Transfer done: '***' [16872]
> 2016-05-18 13:59:06.646 Script: exit
. 2016-05-18 13:59:06.646 Script: Exit code: 0
. 2016-05-18 13:59:06.646 Closing connection.
. 2016-05-18 13:59:06.646 Sending special code: 12
. 2016-05-18 13:59:06.646 Sent EOF message
script2.log:
< 2016-05-18 13:59:27.223 226 Transfer complete.
> 2016-05-18 13:59:27.223 MDTM 20160518023118 ***
< 2016-05-18 13:59:27.239 213 File modification time set.
. 2016-05-18 13:59:27.239 Upload successful
. 2016-05-18 13:59:27.239 Transfer done: '***' [16872]
> 2016-05-18 13:59:27.239 Script: exit
. 2016-05-18 13:59:27.239 Script: Exit code: 0
. 2016-05-18 13:59:27.239 Disconnected from server
The problem can be observed already during the first execution of bat1 or bat2.
Although return codes from WinSCP.exe and WinSCP.com are '0', already one of the commands
or
just does not execute.
After the parallel run of above scripts, we cannot run .bat files from Informatica.
The mechanism of running .bat files is that pmserver.exe starts cmd.exe which executes .bat file.
Procmon shows that the cmd.exe starts to read the .bat file, but it exits the thread just after that, so the content of .bat is never executed.
We didn't find anything in Windows logs and antivirus logs. The only unusual part (thread exit right after reading .bat) is visible in Procmon log. However, exit code is 0.
As I said, the only solution I know so far is to restart pmserver.exe.
The problem was also there when we used portable version 5.7.6.