Scheduled Task running script failing Windows 10
I've just been getting stuck trying to Schedule a Task running WinSCP - a pretty simple task that SFTPs a directory from a server and downloads it all to a backup drive locally.
It repeatedly failed with a black WinSCP window (if running
/console
) or the process just hanging (without /console
), seemingly doing nothing. The logs showed reported it was getting stuck just after reporting its Process ID into the log. I could verify this and see the process sitting there consuming CPU but not any network traffic.
I tried several different steps to resolve, but ultimately what fixed it was changing the command line option for logging from
/log
to /logxml
- I only found this because I was trying to find more details in the log to determine the issue.
Presumably a bug? I thought I would submit this here for your info.
Details follow:
-------------
I could run the script from command prompt successfully, here's the command:
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /log="C:\Users\username\WinSCP-backup-script.log" /ini=nul /script="C:\Users\username\WinSCP-backup-script.script"
open sftp://user@000.111.222.333/ -hostkey="ssh-ed25519 255 [alphanumeric-code]" -privatekey="C:\Users\user\SSHKeys\ssh-private-key.ppk" cd /home/data/backup lcd H:\!SFTP_Backups get -speed=2048 -neweronly * exit # Execute the script using a command like: # "C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\writable\path\to\log\WinSCP.log" /ini=nul /script="C:\path\to\script\script.txt"
The Scheduled Task (where the problem began) was set to run as my user account, while logged in, following all the usual settings in the guide. Here's my command-line options:
/log="C:\Users\username\WinSCP-backup-script.xml" /ini=nul /script="C:\Users\username\WinSCP-backup-script.script"
/xmllog=
and it suddenly began working. Same log folder/permissions, nothing else changed.
Here's a sample of the log entries (before changing over to xml):
. 2021-07-07 21:29:37.828 -------------------------------------------------------------------------- . 2021-07-07 21:29:37.828 WinSCP Version 5.19.1 (Build 11552) (OS 10.0.19041 - Windows 10 Enterprise) . 2021-07-07 21:29:37.828 Configuration: nul . 2021-07-07 21:29:37.829 Log level: Normal . 2021-07-07 21:29:37.829 Local account: COMPUTERNAME\username . 2021-07-07 21:29:37.829 Working directory: C:\Users\username . 2021-07-07 21:29:37.829 Process ID: 28360