Skip to content

Windows Scheduler

We will move every .zip from C:\data\ to sftp://monitor02@10.0.0.24/incoming/ every ten minutes. The new connect move command mirrors send --delete: files land on the remote side and disappear locally once the transfer succeeds.

  1. Create an alias with stored credentials

Open Command Prompt and run:

Command Prompt
C:\> connect alias add
Alias name: job1
Endpoint (no folder, e.g. sftp://host or s3://bucket): sftp://monitor02@10.0.0.24
SFTP password (optional; recommended to leave blank in URI): ****
Connection test: OK
Alias 'job1' saved. You can now use it as @job1/.. in commands.

The alias encrypts the password inside %USERPROFILE%\.connect\connect_aliases.enc, so it is safe to reuse from scheduled tasks.

  1. Trust the host key and verify access
Command Prompt
C:\> connect ls @job1/
The key (SHA256:v/goXq57T++lsDmeYduLCRJEUzEqf9u9OybWiHt3VRc) of 10.0.0.24:22 is unknown. Do you want to add this key to known_hosts (y/n): y
Name Size ModTime
incoming/ - 2024-12-10T10:44:51Z

Run the command again to ensure the key is stored and no longer prompts.

  1. Create a batch file that runs connect move

Use Notepad to save C:\connect\job1.bat with the following content:

C:\connect\job1.bat
@echo off
c:\connect\connect.exe move ^
--batch --no-color --parallel 3 ^
"C:\data\*.zip" ^
@job1/incoming/ >> c:\connect\job1.log 2>&1
  1. Test the script manually
Command Prompt
C:\> c:\connect\job1.bat
C:\> type c:\connect\job1.log
2024/12/10 15:36:12 INFO Moving files to sftp://monitor02@10.0.0.24/incoming/

Clear the log if you want a fresh file before scheduling: type nul > c:\connect\job1.log.

  1. Register the task in Task Scheduler
  1. Press Win + R, run taskschd.msc.
  2. Action → New Folder… create a folder named SFTP (optional for grouping jobs).
  3. Inside that folder choose Action → Create Task…
    • General tab: Name = Job1, select Run whether user is logged on or not.
    • Triggers tab: add a trigger with On a schedule, repeat every 10 minutes indefinitely.
    • Actions tab: choose Start a program and point to C:\connect\job1.bat.
    • Conditions tab: disable idle/power checks so the task always runs.
    • Settings tab: enable Allow task to be run on demand and set If the task is already running → Do not start a new instance.
  4. Confirm with OK. When prompted for credentials, supply the Windows account that installed the alias.
  1. Validate the scheduled run

Right-click the task and select Run. Inspect C:\connect\job1.log for the latest timestamp or check the Task Scheduler History tab to confirm success.