Here is the script I am trying to run:
& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
/log="C:\FTP Files\LogFiles\WinSCP.log" /ini=nul `
"open name_of_site" `
"cd /out" `
"lcd W:\" `
"get *" `
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
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.