Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: Download Files to Network Drive Using Different Credentials

This does not really look like WinSCP question. Did you verify that the W: drive is actually mapped in your task scheduler session? I guess it's not.
Nate T.

Download Files to Network Drive Using Different Credentials

Here is the script I am trying to run:

& "C:\Program Files (x86)\WinSCP\" `
  /log="C:\FTP Files\LogFiles\WinSCP.log" /ini=nul `
  /command `
    "open name_of_site" `
    "cd /out" `
    "lcd W:\" `
    "get *" `
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
  Write-Host "Success"
  Write-Host "Error"
exit $winscpResult

When I manually run this Poweshell script, it runs without any issue. But when I run it to Task Scheduler, it fails to run.

This is part of the WinSCP log:

> 2020-06-08 09:35:01.593 Script: lcd W:\

< 2020-06-08 09:35:01.593 Script: Error changing directory to 'W:\'.
< 2020-06-08 09:35:01.593 System Error.  Code: 3.

< 2020-06-08 09:35:01.593 The system cannot find the path specified
. 2020-06-08 09:35:01.593 Script: Failed
. 2020-06-08 09:35:01.593 Script: Exit code: 1
. 2020-06-08 09:35:01.593 Closing connection.

On my computer, W: is mapped to a network location and is connecting with different credentials. Is there a way to run this script automatically so that I can download a file to a network location?

Also, I have tried this multiple times and have tried running the task as both the user I am logged in as and as the user that has access to the network location.