"C:\Program Files\WinSCP\winscp.com" /script="m:\jobs\sftp_send_commands.txt" /xmllog="m:\jobs\sftp_send_xmllog.20130820.txt"
Running the command as-is from the command line always works and generates an xmllog file.
We are attempting to use the command is in a batch file that checks the errorlevel for a return code. When the return code from WinSCP is 0, an xmllog file is created every time. The batch file also redirects standard and error output to a general log file (see next code segment), separate from the xmllog file.
In the batch file, the run command is:
"C:\Program Files\WinSCP\winscp.com" /script="m:\jobs\sftp_send_commands.txt" /xmllog="m:\jobs\sftp_send_xmllog.20130820.txt" >> "m:\jobs\sftp_send_20130820.log" 2>&1
With the next line in the file the check for the return code/errorlevel.
sftp_send_xmllog.20130820.txt is the intended xmllog
sftp_send_20130820.log is the general job log
When the batch file is run manually, with command prompt run as domain user "jobs", everything works appropriately, including the generation of an xmllog file when the return code is zero or non-zero. Some winscp messages are sent to the general log file (via redirection)
When the batch file is run via the Windows task scheduler as domain user "jobs", the winscp binary is returning non-zero (caught by checking the errorlevel), not uploading any files, and no xmllog file is generated. There is also no output via the pipe to the general log file (via redirection).
WinSCP verison: 5.1.7 (build 3446)
OS version: Win2003 (fully patched)
"jobs" domain user has read/write access to m:\jobs and m:\upload directory trees.
Contents of sftp_send_commands.txt file (sensitive data stripped out)
option batch abort option confirm off open sftp://user:email@example.com -hostkey="ssh-rsa 1024 a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9:a9" put m:\upload\*.txt / close exit
Thank you in advance for your help