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:
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:
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
Windows UAC is in play.
Windows Task Scheduler option to "Run with highest privileges" is enabled, which supposedly bypasses UAC issues.
[/code]
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]