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

Advertisement

stevewa
Joined:
Posts:
1

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
42,328
Location:
Prague, Czechia

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/

Reply with quote

Advertisement

You can post new topics in this forum