winscp.com run failure from Windows Scheduler

Advertisement

JJAnderson
Joined:
Posts:
11
Location:
USA

winscp.com run failure from Windows Scheduler

WinSCP version: 5.5.4
Windows Version: Win2008r2 Enterprise
Scripting Automation/When run from Windows Task Scheduler

Code in batch (.bat) file, called from Windows Task Scheduler.
The following line of code produces an ERRORLEVEL of 1, but only when run via Windows Task Scheduler (One long line, ^ used to make it easy to read:

"D:\Program Files (x86)\WinSCP\winscp.com" ^
   /script="D:\jobs\FTPSync2\SFTPsync2.ftp-commands.20150302_133258.txt" ^
   /log="D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log" ^
   /xmllog="D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log" ^
   /xmlgroups ^
   >>"D:\jobs\FTPSync2\SFTPsync2.20150302.log" 2>&1

The script is not run and no output logs are created.
Windows Task Scheduler is run as the local SYSTEM account.
Windows Task Scheduler option to "Run with highest privileges" is enabled.
Confirmed that the SYSTEM account has write access to D:\jobs\FTPSync2\
(even granting 'everyone' account full control to D:\jobs\FTPSync2\ did not change behavior)
Full, double-quoted paths/file names are used at all times.
Attempted local admin and non-local admin (with necessary file rights) for runas user in Task scheduler, no luck.
Can run manually (.bat) from command line with no issues.

Updated batch file to include the following:
ECHO test > "D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log"
"D:\Program Files (x86)\WinSCP\winscp.com" ^
   /script="D:\jobs\FTPSync2\SFTPsync2.ftp-commands.20150302_133258.txt" ^
   /log="D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log" ^
   /xmllog="D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log" ^
   /xmlgroups ^
   >>"D:\jobs\FTPSync2\SFTPsync2.20150302.log" 2>&1

The echo works, the WinSCP execution fails if (.bat) run from Windows Task Scheduler
Runs without error when run manually from command prompt.

Added the following to ensure the runas user (username variable) is who we think it is
ECHO SET > "D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log"
ECHO test >> "D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log"
"D:\Program Files (x86)\WinSCP\winscp.com" ^
   /script="D:\jobs\FTPSync2\SFTPsync2.ftp-commands.20150302_133258.txt" ^
   /log="D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log" ^
   /xmllog="D:\jobs\FTPSync2\SFTPsync2.ftplog_20150302_133258.log" ^
   /xmlgroups ^
   >>"D:\jobs\FTPSync2\SFTPsync2.20150302.log" 2>&1


Windows UAC is in play.
Windows Task Scheduler option to "Run with highest privileges" is enabled, which supposedly bypasses UAC issues.


[/code]

Reply with quote

Advertisement

JJAnderson
Joined:
Posts:
11
Location:
USA

Is there a way to get WinSCP to flush a log no matter the error? To stdout or stderr perhaps?

I forgot to mention that "D:\jobs\FTPSync2\SFTPsync2.20150302.log"
is also free from any data related to the error

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: winscp.com run failure from Windows Scheduler

I'm not sure it's the root cause of your problem, but you definitely cannot use the same file for /log, /xmllog and output redirection (>). You have to use three separate logs.

Reply with quote

JJAnderson
Joined:
Posts:
11
Location:
USA

log and xmllog are the same, the redirect log is different
SFTPsync2.ftplog_20150302_133258.log
vs
SFTPsync2.20150302.log

Sorry, I know it can be eye-crossing

Reply with quote

Advertisement

You can post new topics in this forum