Differences
This shows you the differences between the selected revisions of the page.
2021-02-02 | 2023-03-11 | ||
anyone can (martin) | using -username/-password + -passwordsfromfiles (martin) | ||
Line 13: | Line 13: | ||
In [[scripting|script]], you can replace actual credentials with reference to environment variables. You can then call WinSCP from a batch file that sets these variables. The batch file itself then serves as a "configuration file". | In [[scripting|script]], you can replace actual credentials with reference to environment variables. You can then call WinSCP from a batch file that sets these variables. The batch file itself then serves as a "configuration file". | ||
- | For example, following script (''example.txt''): | + | For example, the following script (''example.txt'')((Using [[scriptcommand_open#username|''-username'']] and [[scriptcommand_open#password|''-password'']] switches instead of specifying credentials in [[session_url|session URL]], because the switches do not require the values to be [[session_url#special|URL-encoded]].)): |
<code winscp> | <code winscp> | ||
- | open sftp://%USERNAME%:%PASSWORD%@example.com | + | open -username=%USERNAME% -password=%PASSWORD% sftp://example.com/ |
... | ... | ||
</code> | </code> | ||
Line 27: | Line 27: | ||
set PASSWORD=mypassword | set PASSWORD=mypassword | ||
winscp.com /script=example.txt | winscp.com /script=example.txt | ||
+ | </code> | ||
+ | ---- | ||
+ | Another way is to store the password to a separate file and use [m]-passwordsfromfiles[/m] (&beta_feature): | ||
+ | <code winscp> | ||
+ | open -password=C:\path\password.txt -passwordsfromfiles sftp://username@example.com/ | ||
</code> | </code> | ||