Differences

This shows you the differences between the selected revisions of the page.

2014-10-15 2015-01-08
avoid using pageant for automation (martin) it's not only about configuration, but environment too + solution for mapped drive issue (martin)
Line 1: Line 1:
====== My script works fine when executed manually, but fails or hangs when run by Windows Scheduler, SSIS or other automation service. What am I doing wrong? ====== ====== My script works fine when executed manually, but fails or hangs when run by Windows Scheduler, SSIS or other automation service. What am I doing wrong? ======
-You probably depend on your configuration of WinSCP. Note that when using registry as [[config|configuration storage]], the settings are accessible only for your Windows account. When the script is run from Windows Scheduler, SSIS, DTS or other automation service, it is typically run under different (service) account that cannot access your configuration.+You probably depend on your configuration of WinSCP or your Windows account environment.
Possible consequences are: Possible consequences are:
Line 8: Line 8:
  * Access to files on mapped network drives fails, because the drives are not mapped for the service's account.   * Access to files on mapped network drives fails, because the drives are not mapped for the service's account.
  * You rely on [[ui_pageant|Pageant authentication]], but the Pageant is running in a different Windows session, so it cannot talk to an automated instance of WinSCP.((Learn about [[http://blogs.technet.com/b/voy/archive/2007/02/23/services-isolation-in-session-0-of-windows-vista-and-longhorn-server.aspx|Windows Session 0 isolation]].))   * You rely on [[ui_pageant|Pageant authentication]], but the Pageant is running in a different Windows session, so it cannot talk to an automated instance of WinSCP.((Learn about [[http://blogs.technet.com/b/voy/archive/2007/02/23/services-isolation-in-session-0-of-windows-vista-and-longhorn-server.aspx|Windows Session 0 isolation]].))
 +
 +Note that when using registry as [[config|configuration storage]], the settings are accessible only for your Windows account. When the script is run from Windows Scheduler, SSIS, DTS or other automation service, it is typically run under different (service) account that cannot access your configuration.
To check what [[config|configuration storage]] is used, whether a site name was recognized or under what Windows account the script is running, inspect a beginning of [[logging|session log]]. For example, following log shows that the configuration was read from Windows registry, the script was running under local account ''martin'' and ''mysession'' was recognized as a site name. To check what [[config|configuration storage]] is used, whether a site name was recognized or under what Windows account the script is running, inspect a beginning of [[logging|session log]]. For example, following log shows that the configuration was read from Windows registry, the script was running under local account ''martin'' and ''mysession'' was recognized as a site name.
Line 32: Line 34:
    * Alternatively use [[config|INI file]] instead of registry to store the configuration to make sure the [[session_configuration#site|site]] (and/or other settings) can be accessed by all accounts. ((You can also [[config#transfer|transfer the site]] (and/or other settings) to the service's account instead.))     * Alternatively use [[config|INI file]] instead of registry to store the configuration to make sure the [[session_configuration#site|site]] (and/or other settings) can be accessed by all accounts. ((You can also [[config#transfer|transfer the site]] (and/or other settings) to the service's account instead.))
    * Good practice is to develop your scripts with [[scripting#configuration|configuration isolated from GUI]].     * Good practice is to develop your scripts with [[scripting#configuration|configuration isolated from GUI]].
 +  * Use an UNC path to a shared folder, instead of a path to the drive mapped to the shared folder. Make sure the service's account has an access to the shared folder.
  * Instead of Pageant authentication, use explicit private key authentication (using ''[[scriptcommand_open|-privatekey]]'' and ''[[scriptcommand_open|-passphrase]]'' switches).   * Instead of Pageant authentication, use explicit private key authentication (using ''[[scriptcommand_open|-privatekey]]'' and ''[[scriptcommand_open|-passphrase]]'' switches).

Last modified: by martin