An entry's 'Run Command' field can contain a command that will be run when the Run Command action is selected. Anything that you can do in Windows' "Start → Run" can be used here.
In addition, Password Safe is able to pass arguments to the command such as the entry's username, password, etc., as described below. This allows you to 'program' fairly complex actions, such as invoking a remote access program (PuTTY, for example) and passing it the username and password associated with the entry.
In general, 'variables' are replaced with values associated with them before being passed to the computer for execution. The dollar ('$') sign is used to indicate a variable.
appdir | Directory containing the Password Safe application. See notes 1 & 2 below. |
dbdir | Directory of current open database. See notes 1 & 2 below. |
fulldb | Full path, filename and extension of current open database. See note 2 below. |
dbname | Current open database filename. |
dbextn | Current open database extension. |
g or group | Group (full tree structure back to root with groups separated by periods). |
G or GROUP | The group containing this entry. |
t or title | Title |
u or user | Username |
p or password | Password |
e or email | |
a or autotype | AutoType. See Note 5 below. |
url | URL |
n or n[0] | The complete Notes field (also: notes or notes[0]). See note 3 below. |
n[i] or notes[i] | ith line of the Notes field counting from the start, i.e., i=1 is the first line, i=2 means the second line etc. See note 4 below. |
n[-i] or notes[-i] | ith line of the Notes field counting from the end, i.e., i=1 is the last line, i=2 means the penultimate line etc. See note 4 below. |
Note: Be sure to add quotes around your string if required e.g., if your database directory contains spaces, to access a text file in it based on your open database name, you would need the following (with quotes):
'$dbdir\\$dbname.txt'
Notice that the backslash is escaped so that the '$dbname' is recognised as a variable.
On Windows, the normal substitution of environment variables (specified as %variable_name%) is performed. For example: '%windir%\notepad.exe' could become (depending on your installation) 'C:\Windows\notepad.exe'. Current values set in your environment can be determined by running 'cmd.exe' and issuing the 'set' command without any parameters. Any unknown environment variable is left unchanged in the Run Command e.g., %xyz%\notepad.exe remains as %xyz%\notepad.exe if variable 'xyz' is not set. Note: Windows environment variables are not case sensitive.
"C:\Program Files\PuTTY\putty.exe" -ssh ${u}@myHost 22 -pw $p
${autotype}(\p\n)"${appdir}\pwsafe.exe" \UNC\path\to\database.psafe3