-1

I am new to using winSCP and Windows Task Scheduler. I am working on connecting to an external FTP server and copying its contents to a local directory on my PC.

When running my scheduled task, winSCP prompts me credentials to connect to the FTP server. If I press enter and submit nothing, the program runs as intended and copies all files to my local directory. If I do not interact, the program times out and does not complete.

What can I do to remove the need for entering credentials when connecting to the server? I would like this task to be fully automated. I'm assuming there is a line I can add to my script file to automate this?

Here is my winSCP default settings: (https://i.sstatic.net/UltbfzED.png)

Here is the Action being prompted by my Windows Task Scheduler: Action: Start a Program Program/script: C:\Users\furmand1\AppData\Local\Programs\WinSCP\WinSCP.com Add arguments: /log="C:\Users\furmand1\Desktop\Log\winscp.log" /script="C:\Users\furmand1\Desktop\Script\Script.txt"

Here is the Script file I am running through winSCP:

# Connect
open 10.201.47.178
# Change directory
lcd C:\Users\furmand1\Desktop\FTP
# Download file to the local directory
mget *.*
# Disconnect
close
# Exit WinSCP
exit

Here is the Log file winSCP returns if I do not interact:

. 2024-06-24 16:27:59.663 --------------------------------------------------------------------------
. 2024-06-24 16:27:59.663 WinSCP Version 6.1.1 (Build 13736 2023-06-21) (OS 10.0.19045 – Windows 10 Enterprise)
. 2024-06-24 16:27:59.663 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2024-06-24 16:27:59.663 Log level: Normal
. 2024-06-24 16:27:59.663 Local account: NAM\furmand1
. 2024-06-24 16:27:59.663 Working directory: C:\WINDOWS\system32
. 2024-06-24 16:27:59.663 Process ID: 29132
. 2024-06-24 16:27:59.678 Ancestor processes: WinSCP, ...
. 2024-06-24 16:27:59.678 Command-line: "C:\Users\furmand1\AppData\Local\Programs\WinSCP\WinSCP.exe" /console=6.1.1 /consoleinstance=_21632_881 "/log=C:\Users\furmand1\Desktop\Log\winscp.log" "/script=C:\Users\furmand1\Desktop\Script\Script.txt" 
. 2024-06-24 16:27:59.678 Time zone: Current: GMT-4, Standard: GMT-5 (Eastern Standard Time), DST: GMT-4 (Eastern Daylight Time), DST Start: 3/10/2024, DST End: 11/3/2024
. 2024-06-24 16:27:59.685 Login time: Monday, June 24, 2024 4:27:59 PM
. 2024-06-24 16:27:59.685 --------------------------------------------------------------------------
. 2024-06-24 16:27:59.685 Script: Retrospectively logging previous script records:
> 2024-06-24 16:27:59.685 Script: open 10.201.47.178
. 2024-06-24 16:27:59.685 --------------------------------------------------------------------------
. 2024-06-24 16:27:59.685 Session name: 10.201.47.178 (Ad-Hoc site)
. 2024-06-24 16:27:59.685 Host name: 10.201.47.178 (Port: 21)
. 2024-06-24 16:27:59.685 User name:  (Password: No, Key file: No, Passphrase: No)
. 2024-06-24 16:27:59.685 Transfer Protocol: FTP
. 2024-06-24 16:27:59.685 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec
. 2024-06-24 16:27:59.685 Disable Nagle: No
. 2024-06-24 16:27:59.685 Proxy: None
. 2024-06-24 16:27:59.685 Send buffer: 262144
. 2024-06-24 16:27:59.685 UTF: Auto
. 2024-06-24 16:27:59.685 FTPS: None [Client certificate: No]
. 2024-06-24 16:27:59.685 FTP: Passive: Yes [Force IP: Off]; MLSD: Off [List all: Off]; HOST: Off
. 2024-06-24 16:27:59.685 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2024-06-24 16:27:59.685 Cache directory changes: Yes, Permanent: Yes
. 2024-06-24 16:27:59.685 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2024-06-24 16:27:59.685 Timezone offset: 0h 0m
. 2024-06-24 16:27:59.685 --------------------------------------------------------------------------
. 2024-06-24 16:27:59.701 Username prompt (no username provided)
< 2024-06-24 16:27:59.701 Script: Prompting for credentials...
< 2024-06-24 16:28:52.057 Script: Connecting to 10.201.47.178 ...
. 2024-06-24 16:28:52.057 Connecting to 10.201.47.178 ...
. 2024-06-24 16:28:52.073 Connected with 10.201.47.178. Waiting for welcome message...
< 2024-06-24 16:28:52.073 220 R-30iB mate FTP server ready. [LR V9.30P/27]
> 2024-06-24 16:28:52.073 USER 
< 2024-06-24 16:28:52.095 230 User logged in [NORM].
> 2024-06-24 16:28:52.095 SYST
< 2024-06-24 16:28:52.095 215 UNKNOWN [LR V9.30P/27].
> 2024-06-24 16:28:52.095 FEAT
< 2024-06-24 16:28:52.111 500 Command not understood.
< 2024-06-24 16:28:52.111 Script: Connected
. 2024-06-24 16:28:52.111 Connected
. 2024-06-24 16:28:52.111 --------------------------------------------------------------------------
. 2024-06-24 16:28:52.111 Using FTP protocol.
. 2024-06-24 16:28:52.111 Doing startup conversation with host.
< 2024-06-24 16:28:52.111 Script: Starting the session...
> 2024-06-24 16:28:52.111 PWD
< 2024-06-24 16:28:52.111 257 "md:\" is current directory.
. 2024-06-24 16:28:52.111 Getting current directory name.
. 2024-06-24 16:28:52.111 Startup conversation with host finished.
< 2024-06-24 16:28:52.111 Script: Session started.
< 2024-06-24 16:28:52.111 Script: Active session: [1] 10.201.47.178
< 2024-06-24 16:28:52.111 Script: Terminated by user.
. 2024-06-24 16:28:52.111 Script: Exit code: 1
. 2024-06-24 16:28:52.126 Disconnected from server
1
  • Does the username have to be empty? Or does the server accept any value for the username? Commented Jun 25, 2024 at 5:06

1 Answer 1

-1

winSCP can generate its own scripts in winSCP.exe, which I used to update my automated script once I had connected manually. The updated script is:

# Connect
open ftp://user:[email protected]/ -rawsettings FtpForcePasvIp2=1 FtpUseMlsd=1 FtpListAll=1 FtpHost=1
# Change directory
lcd C:\Users\furmand1\Desktop\FTP
# Download file to the local directory
mget *.*
# Disconnect
close
# Exit WinSCP
exit

To generate your own Script, login to your FTP server via winSCP.exe, go to Tabs, go to Generate session URL/code, then go to Script.

Sign up to request clarification or add additional context in comments.

1 Comment

How does his answer the question? What is the solution? To use a random password (user here)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.