I have been trying to make the scheduler work for the past two days. I am trying to sync a folder from a remote server using WinSCP, however I do not want to keep WinSCP running continuously and am thus running it using a batch file. The batch file is below.
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="WinSCP_log.log" /ini=nul ^
/command ^
"open sftp://xxxxxxxxxxxxxxxxx -hostkey=""xxxxxxxxxxxxxxxxxxxxx""" ^
"cd /data/remotexxxxxx" ^
"lcd C:\localxxxxx" ^
"synchronize local" ^
It runs fine when I just run the batch file. When using the Windows Task Scheduler to run every 20 minutes it does not run. However, even in the Scheduler if I double click and run manually it works fine. I even tried converting the batch file to a .exe, but face the same issue there.
The Windows Task Scheduler settings are -
Program/Script: /Directory/sync_winscp.bat Arguments: Start in: /Directory
And similarly for the .exe file
Program/Script: /Directory/sync_winscp.exe Arguments: Start in:
I also tried -
Program/Script: .../Win32/cmd.exe Arguments: /Directory/sync_winscp.bat Start in:
It is running with highest privileges and does not have a timeout.
Update: I also have another .bat file to call python and run a script daily which runs perfectly fine.