## KeeAutoExec

Copyright © 2009-2022 Dominik Reichl. Distributed under the terms of the GNU General Public License v2.

This KeePass plugin allows to automatically open additional databases when opening a database.

### Installation / Uninstallation

To install the plugin, copy the `KeeAutoExec.dll`, `KeeAutoExec.plgx` and `KeeAutoExec_ReadMe.html` files into the `Plugins` folder (KeePass can open this folder: menu 'Tools' → 'Plugins' → button 'Open Folder') and restart KeePass.

To uninstall the plugin, delete the three files.

### Usage

First of all, create a new group in your database and name it "AutoOpen" (without the quotes).

Each non-expired entry in this group corresponds to a database that should be opened automatically when the current database is opened. The fields of each entry specify the following:

- Title: Ignored by the plugin; can be used for comments.
- User name: Must contain the path to the key file, if one should be used. The path can be either absolute or relative to the directory containing `KeePass.exe`.
- Password: The master password for the database to open. If no password is required, leave this field empty.
- URL: Path to the database file to open. The path can be either absolute or relative to the directory containing `KeePass.exe`.
- Notes: Ignored by the plugin; can be used for comments.

Disabling entries. If you want to disable an entry in the "AutoOpen" group (such that KeeAutoExec does not automatically open it), you can mark the entry as expired. Alternatively, you can add a custom entry string "Enabled" with the value "False" (without the quotes).

Direct key file. If the entry has a file attachment named "KeyFile.bin" (without the quotes), this is used as key file (only if no key file path has already been specified using the user name field).

Key provider. If the master key includes data supplied by a key provider plugin, specify the name of the key provider as value of the custom entry string "KeyProvider".

Windows user account. If the master key includes a Windows user account key, you can indicate this by creating a custom entry string "UserAccount" with the value "True".

Connection properties. The properties of the connection to the server that provides the database file can be specified using the following custom entry strings.

- Server credentials. When opening a database from a URL, the credentials for accessing the file on the server can be specified using the custom entry strings "IocUserName" and "IocPassword". These strings must not contain new-line characters.
- Timeout. The request timeout in milliseconds can be specified using the custom entry string "IocTimeout".
- Pre-authentication. To specify whether to use pre-authentication for the request, set the string "IocPreAuth" to "True" or "False" (the default is an automatic detection).
- User agent. To override the name of the user agent (for HTTP, HTTPS, WebDAV, etc.), set it as value of the string "IocUserAgent".
- 100-Continue responses. To specify whether to expect 100-Continue responses (for HTTP, HTTPS, WebDAV, etc.), set the string "IocExpect100Continue" to "True" or "False" (the default is an automatic detection).
- Passive mode. To specify whether to use the passive mode (for FTP, etc.), set the string "IocPassive" to "True" or "False" (the default is an automatic detection).
- Advanced connection properties. For experts. Advanced connection properties can be specified via the "IocProperties" string. This corresponds to the `PropertiesEx` element of a connection information object in a KeePass configuration file. If a property is specified both via "IocProperties" and via another "Ioc*" string, then the "Ioc*" string (not "IocProperties") takes precedence.

Existence checks.

- If you create a custom entry string named "SkipIfNotExists" and value "True", the plugin will not attempt to open the database file if it does not exist (no warning message will be shown in this case).
- If you create a custom entry string named "SkipIfKeyFileNotExists" and value "True", the plugin will not attempt to open the database file if the key file does not exist (no warning message will be shown in this case).

Computer/device ID check. The custom entry string "IfDevice" (without the quotes) may contain a comma-separated list of computer/device IDs or negated computer/device IDs (with the prefix '`!`') on which the database is opened automatically. For example, if the string is "Pqr, Xyz", the database is opened automatically only on computers/devices called Pqr or Xyz. If the string is "!Pqr, !Xyz", the database is opened automatically on all computers/devices that are called neither Pqr nor Xyz. On Windows, the computer/NetBIOS name is used as ID; on Linux, the host name is used as ID; on Android, the Android device ID is used.

Order. If multiple databases should be opened, KeeAutoExec by default opens them in the order that the entries are stored in the database (in unsorted mode; you need to turn off sorting to see this order). However, you also can explicitly specify/override the order by defining priorities. To do this, create a custom entry string "Priority" (without the quotes) in each entry and set it to a number. Lower numbers mean higher priority; higher numbers mean low priority. Negative numbers are allowed. Example: you define an entry for database `A.kdbx` with the "Priority" field set to 50, a `B.kdbx` entry with priority 100, and a `C.kdbx` entry with priority -10. Then, KeeAutoExec would open the databases in order `C.kdbx`, `A.kdbx`, `B.kdbx`. If you do not specify a priority, KeeAutoExec assumes consecutive numbers, starting from 0 (i.e. the first database has a priority of 0, the second one 1, etc.).

Focus restoration. By default, when KeeAutoExec opens another database, this database is focused. If you prefer the current database to continue having the focus (i.e. the database opened by KeeAutoExec is opened in the background), create a custom entry string "Focus" with the value "Restore". This setting is ignored when opening a database manually using a menu command in 'File' → 'Open (KeeAutoExec)'.

Placeholders. All strings are Spr-compiled, i.e. placeholders and environment variables can be used.

Manual opening. Auto-open entries can also be executed manually via 'File' → 'Open (KeeAutoExec)'.

Hiding menu items. In order to hide an entry from the 'File' → 'Open (KeeAutoExec)' menu, set its custom string "Visible" to "False".

### Version History

- 2.6
  - Added support for specifying advanced connection properties via the "IocProperties" string.
- 2.5
  - File paths (in the URL field and in the user name field) may now optionally be enclosed in double quotes.
- 2.4
  - The menu item texts are now partially Spr-compiled (only placeholders that are non-active and unlikely to change while the menu is open).
- 2.3
  - Added support for limiting an item to specific computers/devices via the "IfDevice" string.
  - The plugin is now provided in dual form (DLL and PLGX).
- 2.2
  - Added support for specifying the request timeout via the "IocTimeout" string.
  - Added support for specifying whether to use pre-authentication via the "IocPreAuth" string.
  - Added support for overriding the user agent name (for HTTP, HTTPS, WebDAV, etc.) via the "IocUserAgent" string.
  - Added support for specifying whether to expect 100-Continue responses via the "IocExpect100Continue" string.
  - Added support for specifying whether to use the passive mode (for FTP, etc.) via the "IocPassive" string.
  - If the string "SkipIfKeyFileNotExists" is set to "True", KeeAutoExec now does not try to open the database file anymore if the key file does not exist.
- 2.1
  - If the custom entry string "Visible" is set to "False", the entry now does not appear in the 'File' → 'Open (KeeAutoExec)' menu anymore.
- 2.0
  - Auto-open items can now also be executed manually via 'File' → 'Open (KeeAutoExec)'.
  - Entries having a custom entry string "Enabled" with the value "False" are now ignored (this is an alternative to marking the entries as expired).
  - If an entry has a custom entry string "Focus" with the value "Restore", the database is opened in the background.
  - By setting the custom entry string "UserAccount" to the value "True", you can tell KeeAutoExec that the Windows user account key is part of the master key.
- 1.9
  - Added support for specifying a key provider via the "KeyProvider" string.
- 1.8
  - Expired entries in the "AutoOpen" group are now ignored.
- 1.7
  - If server access credentials are specified (using "IocUserName" and "IocPassword"), the 'Open From URL' dialog is not shown anymore.
- 1.6
  - Added support for auto-opening databases from URLs.
  - Added support for specifying server access credentials using custom entry strings "IocUserName" and "IocPassword" when opening a database from a URL.
- 1.5
  - Added ability to load key file data from an entry attachment.
  - Updated code to use the new context-based Spr compilation.
- 1.4
  - Strings are Spr-compiled now, i.e. placeholders and environment variables can be used.
- 1.3
  - Added ability to specify priorities.
- 1.2
  - Added "SkipIfNotExists" functionality.
- 1.1
  - Minor update.
- 1.0
  - Initial release.

### Links

Latest version of KeeAutoExec:
https://keepass.info/plugins.html#keeautoexec

Support:
https://sourceforge.net/p/keepass/discussion/329221/

Feature requests & bug reports:
https://sourceforge.net/p/keepass/discussion/329220/

Donate:
https://keepass.info/donate.html