Post a reply

Options
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)

Options

Topic review

martin

Re: Script, is there a way to include a file which contains variables in an ini format?

You can save your session to a read-only INI file and use with with /ini=myconfig.ini commandline switch:
https://winscp.net/eng/docs/commandline#configuration
And then use it like
open sessionname

myconfig.ini being:
[Sessions\sessionname]
HostName=example.com
UserName=username
PasswordPlain=password


Or you can actually use the env variables in batch file like this:
call myconfig.bat
winscp.com /ini=nul /command "open %SESSION%" ... "exit"

with myconfig.bat being like:
set SESSION=sftp://username:password@example.com/
stevewa

Script, is there a way to include a file which contains variables in an ini format?

I read the option page
https://winscp.net/eng/docs/scriptcommand_option
but I do not see any choice to include a file
i.e. option include myconfig.ini

I will have many scripts, and to avoid typing the same information in each script, I wish to have those variables in 1 file, ie myconfig.ini
server_host=""

hostkey="ssh-rsa blah blah blah"

and be able to include that file in my script with a command like
option include

or
option import

and have those variables be parsed and loaded in memory and available to the script
(like env variables but not actual env vars)

Is there any feature in WinSCP which can do this?

Thank you.