This is an old revision of the document!
My script works fine when executed manually, but fails when run by Windows Scheduler or other automation tool. What am I doing wrong?
You probably depend on your configuration of WinSCP. Note that when using registry as configuration storage, the settings are accessible only for your Windows account. When the script is run from Windows Scheduler, it is typically run under different account that cannot access your configuration.
Possible consequences are:
- The script “hangs” because the host key (SFTP or SCP) or certificate (FTPS) is not known by the Scheduler’s account and WinSCP asks for its verification.
- The connection fails, because your script depends on stored session, which is not known by the Scheduler’s account.
- Environment variables referenced in script are not resolved, because they are not set by the Scheduler’s account.
Advertisement
Solutions:
- Make sure the host key or certificate is verified under the Scheduler’s account. With SSH you can specify fingerprint of expected hostkey.
- Transfer the stored session (or other settings) to the Scheduler’s account.
- or Use INI file instead of registry to store the configuration. The INI file can be accessed by all accounts.