A user presented the problem in the following way: “I’ve set up a scheduled task for psftp on a Windows 2008 server. The script works fine when I run it manually but when the task runs it just hangs in a status of “running” and never finishes.”
The command was formatted as: psftp username@host -pw [password] -b file.dat
The file.dat contains the commands the user wanted ran in the session.
If you ever try to run a command from the Run window you notice that a command window pops up and quickly shuts down. But a scheduled task doesn’t execute a command in the same manner, instead the task is encapsulating the command and if the command doesn’t exit itself then the task will just remain running. Missing from the .dat file after a couple of lines of mput commands was ‘bye’. Adding ‘bye’ to the end of the file resolved the issue.