Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Batch file works when launched manually but not from Task Scheduler

Did you try to enable logging explicitly using /log command-line switch (instead of relying on the global configuration)?
https://winscp.net/eng/docs/commandline#logging

See also:
howards

Batch file works when launched manually but not from Task Scheduler

I have a batch file that gathers files into some standard folders and then loops through the folders to upload them and their contents with this line:
for /D %%a in ("ToSend\*") do (
"C:\Program Files\WinSCP\WinSCP.com" /command "open myFTPserver" "put %%a" "exit"
)

The batch file runs perfectly when run manually, as well as when "run as" 'AnotherUser'. But when I run it from a Windows Task Schedule that itself "runs as" 'AnotherUser', it all runs as expected except that WinSCP doesn't do anything. I can see from a batch file process log that the WinSCP command is called for each folder, but nothing gets added to the default WinSCP.log and nothing gets uploaded.

If I had to guess, I'd say it's a permissions issue, but 'AnotherUser' has full control over WinSCP and all the scripts and files to upload, etc. Plus, the script schedule is theoretically running as the same user as when I run it manually.

Thoughts?