getpassword2

Reads a password. (version 5.3 or later)

Format

getpassword2 <filename> <password name> <password var> <encrypt str>

Parameters

string <filename>
Password file name.
string <password name>
Password identifier.
string variable <password var>
Variable to store the password.
string <encrypt str>
Password for decrypt <password>.

Return Value

System variable <result>
When the password file can not be written, it is set to 0.
Otherwise, it is set to 1.

Remarks

Retrieves an encrypted password identified by <password name> from the password file <filename>.
The password is decrypted using <encrypt str> and stored in the string variable <password var>.
The same string specified in getpassword2 or setpassword2 command must be specified in <encrypt str>.

If the specified file does not exist, it is newly created.
If the specified password is not stored in the file, the password dialog box appears and the entered password is stored in <password var>.
At the same time, the new password is encrypted and written in the file with the identifier <password name>.

A password file can contain multiple passwords.
Each of them is identified by the password identifier.

Example

getpassword2 'password2.dat' 'foo' password 'Sesame!'
connect 'myhost'
wait 'login:'
sendln 'myname'
wait 'password:'
sendln password
expandenv str "%USERPROFILE%\password2.dat"
getpassword2 str 'foo' password 'Sesame!'
if !result then
	messagebox 'Password was not saved' 'ERROR'
endif

See also