0

I want to schedule a task that for each file in a specific local directory deletes a file with the same name on a remote server's directory.

On the command I run this

for  %f in (*) do start winscp /command "open ftp://user:password@mythost.com/"   "rm %f" "close" "exit"

and it works

but when I run it as a scheduled task and starting the cmd.exe program and passing in the following argument for %f in (*) do start winscp /command "open ftp://user:pass@host.com/" "rm %f" "close" "exit" it doesnt work

what is my problem?

Meir
  • 103

1 Answers1

0

You need to add "/c" at the beginning of the arguments:

/c for  %f in (*) do start winscp  /command "open ftp://user:pass@host.com/"   "rm %f" "close" "exit"

So the complete command would become as follows:

cmd.exe /c for  %f in (*) do start winscp  /command "open ftp://user:pass@host.com/"   "rm %f" "close" "exit"

For more details, see also this thread: https://stackoverflow.com/a/5047185/5538923 .

marcor92
  • 116
  • Good, but now I scheduled the task. Each time the task runs it opens a cmd promp window. Can I stop this? @marcor92 – Meir Jan 08 '21 at 02:37
  • @Meilech in order not to show the cmd prompt window, you can try to remove the "/command" from your arguments. For more details see here: https://winscp.net/forum/viewtopic.php?t=10977 and here: https://winscp.net/eng/docs/commandline#scripting . – marcor92 Jan 08 '21 at 12:09