Topic "winscp.com run failure from Windows Scheduler"

Author Message
JJAnderson
[View user's profile]

Joined: 2015-01-09
Posts: 11
Location: USA
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:

Code:

"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:
Code:

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
Code:

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]
Advertisements
JJAnderson
[View user's profile]

Joined: 2015-01-09
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
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.
_________________
Martin Prikryl
JJAnderson
[View user's profile]

Joined: 2015-01-09
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
JJAnderson wrote:
log and xmllog are the same

OK, but even that is wrong.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License