Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm scripting WinSCP, and need to dynamically pass in a FTP username and password, depending on which environment I'm using.

However, the docs say, "WinSCP does not support providing the passphase from command line or by other means allowing automation"

Is there another way?

share|improve this question
One thing to be aware of (if you weren't already) is that the username and password will be stored in plain text. If there's a console log (or something like doskey is running), it may be possible for someone to retrieve these passwords. – Andrew M. Dec 7 '11 at 23:10
@Redmumba, correct. The password would be exposed to a local attacker, or local malicious code with sufficient privileges. However, there are mitigating factors in our case to prevent escalation. Further, FTP passwords are already vulnerable to network interception. – Matthew Flaschen Dec 8 '11 at 0:09

Have you tried using something like as the address ?

You script can then build this uri depending on you environment.

This example uses sftp but ftp should be similar.

share|improve this answer

The following is what worked for me

created a file called script.text. Following is the content of script.txt

open ftp://uname:pwd@ftpserver_url

then from the command prompt executed the following statement

c:\ "path_to_winscp\WinSCP.exe" /console /script=c:/script.txt
share|improve this answer
Note that I asked about passing it in, whereas you're embedding it in the script. – Matthew Flaschen Jan 25 '13 at 5:40

Use /parameter and %1% and %2% in the script: /console /parameter username password /script=some.script

In some.script:

open ftp://%1%:%2%@servername
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.