### User Configuration Example
Source: https://keepass.info/help/kb/config_enf.html
An example of a user configuration file before merging.
```xml
true
```
--------------------------------
### Example Version Information File
Source: https://keepass.info/help/v2_dev/plg_index.html
This is an example of a version information file that lists two plugins and their versions. The separator character is ':'.
```text
:
MyPlugin1:1.5
MyPlugin2:1.13.2.17
:
```
--------------------------------
### List Entries in KeePass Database with Keyfile
Source: https://keepass.info/help/v2_dev/scr_sc_index.html
Use the ListEntries command to get a machine-readable list of all entries in a KeePass database. This example demonstrates opening the database with both a password and a key file.
```bash
KPScript -c:ListEntries "C:\\KeePass\\MyDb.kdbx" -pw:MyPassword -keyfile:"C:\\KeePass\\MyDb.key"
```
--------------------------------
### VKEY Examples
Source: https://keepass.info/help/base/autotype.html
Examples demonstrating the usage of the {VKEY} command for sending specific key presses, including extended keys and modifier key combinations.
```plaintext
Press and release Enter: {VKEY 13}
Press and release Enter on numeric keypad: {VKEY 13 E}
Send Win+E: {VKEY 91 D}e{VKEY 91 U}
```
--------------------------------
### Start KeePass from Batch File
Source: https://keepass.info/help/base/cmdline.html
Starts KeePass from a batch file using the START command, which allows the batch file to exit immediately after launching KeePass. Ensure KeePass is in the working directory or provide a full path.
```batch
START "" KeePass.exe ..\Database.kdbx -pw:MySecretPw
```
--------------------------------
### Run Notepad and Continue Immediately
Source: https://keepass.info/help/base/placeholders.html
This example demonstrates how to run Notepad and have the command continue without waiting for the application to close. The `/W=0` argument specifies not to wait.
```bash
{CMD:/Notepad.exe/W=0/}
```
--------------------------------
### Hello World KPS Script
Source: https://keepass.info/help/v2_dev/scr_kps_index.html
A basic 'Hello World' example demonstrating the structure of a KPS script file. It uses the MessageService to display an informational message.
```csharp
public static void Main()
{
MessageService.ShowInfo("Hello World!");
}
```
--------------------------------
### Silent Installation with KeePass Installer
Source: https://keepass.info/help/v2/setup.html
Use this command to silently install KeePass via its executable, excluding file associations and including a desktop shortcut.
```bash
KeePass-2.x-Setup.exe /VERYSILENT /MERGETASKS="!FileAssoc,DesktopIcon"
```
--------------------------------
### Get File Hash with PowerShell and Hidden Window
Source: https://keepass.info/help/base/placeholders.html
This example executes a PowerShell command to get the SHA-256 hash of a file. The `/M=C,WS=H` arguments specify to continue immediately and use a hidden window style for PowerShell.
```bash
{CMD:/PowerShell.exe -Command "(Get-FileHash '%SYSTEMROOT%\Win.ini' -Algorithm SHA256).Hash"/M=C,WS=H/}
```
--------------------------------
### KeePass Help URL Examples
Source: https://keepass.info/help/v2_dev/customize.html
Examples of specifying custom help URLs for different viewers like KchmViewer and SumatraPDF. These are used when the 'HelpUrl' configuration option is set.
```text
cmd://"%ProgramFiles%\Ulduzsoft\KchmViewer\kchmviewer.exe" -token "info.keepass.kp2" -showPage "/help/{BASE}" "{APPDIR}\KeePass.chm"
```
```text
cmd://"%ProgramFiles%\SumatraPDF\SumatraPDF.exe" -named-dest "help/{BASE}" "{APPDIR}\KeePass.chm"
```
--------------------------------
### Start Minimized with -minimize
Source: https://keepass.info/help/base/cmdline.html
Use the -minimize option to start KeePass in a minimized state. This may not function correctly on Mono.
```bash
KeePass.exe -minimize
```
--------------------------------
### CSV Import Example with Groups
Source: https://keepass.info/help/kb/imp_csv.html
This example shows a CSV file structure that includes group information for importing entries. The first column specifies the group path, with '\' as the delimiter. Entries without a group path are imported into the root group. Ensure the group delimiter is correctly configured and escaped if necessary.
```csv
"Group","Account","Login Name","Password","Web Site","Comments"
,"Sample Entry 1","User Name","Password","https://keepass.info/","Note"
"Group A\Group B","Sample Entry 2","tom@example.com","Tom'sPass",,"This is a sample note"
"Group A","Sample Entry 3","Fred","Password\,with\\escaped\"characters",,
"Group C\Group D.1","Sample Entry 4","Michael321","12345","https://keepass.info/",
```
--------------------------------
### Start Remote Desktop Connection
Source: https://keepass.info/help/base/autourl.html
Use this URL to initiate a Windows remote desktop connection. Ensure mstsc.exe is accessible.
```url
cmd://mstsc.exe
```
--------------------------------
### Auto-Type Sequence with Command Execution
Source: https://keepass.info/help/base/security.html
This auto-type sequence example illustrates how a combination of login credentials and a command execution placeholder can be used to run a program like Calc.exe after a login.
```plaintext
{USERNAME}{TAB}{PASSWORD}{ENTER}{VKEY 91}{T-CONV:/%43%61%6C%63%2E%65%78%65/Uri-Dec/}{VKEY 13}
```
--------------------------------
### Configure KeePass to Open Specific Database on Startup via Shortcut
Source: https://keepass.info/help/kb/faq.html
Automate opening a specific KeePass database when KeePass starts by creating a shortcut to KeePass.exe. Append the database path to the target field in the shortcut properties. Ensure paths with spaces are enclosed in quotes.
```bash
"C:\Program Files\KeePass\KeePass.exe" "C:\Path\To\Your\Database.kdbx"
```
--------------------------------
### Silent Installation with KeePass MSI Package
Source: https://keepass.info/help/v2/setup.html
Use this command to silently install KeePass for all users via its MSI package, without a desktop shortcut and without optimizing start-up performance.
```bash
MsiExec.exe /i "C:\Path\KeePass-2.x.msi" /qn ALLUSERS=1 KPS_OPTIONS="!DesktopIcon,!PreLoad"
```
--------------------------------
### Secret String Splitting Example
Source: https://keepass.info/help/v2/autotype_obfuscation.html
Illustrates how a secret string is character-wise split into two parts for obfuscation.
```text
y il m o d .c
m ma @ ypr vi er om
```
--------------------------------
### Example of Merging Lists Based on Node Keys
Source: https://keepass.info/help/kb/config_enf.html
Demonstrates how KeePass merges list items by creating node keys from child elements. This example shows the user configuration, enforced configuration, and the resulting merged configuration for '/Configuration/Custom/Item' elements where the 'Key' child node determines the merge.
```xml
-
Example_A
21
-
Example_B
22
-
Example_C
23
```
```xml
-
Example_B
40
```
```xml
-
Example_A
21
-
Example_B
40
-
Example_C
23
```
--------------------------------
### Add New Entry with Title and Password
Source: https://keepass.info/help/v2_dev/scr_sc_index.html
Adds a new entry to the database with a specified title and password. This is a basic example; other fields like URL can also be provided.
```bash
KPScript -c:AddEntry "C:\\KeePass\\MyDb.kdbx" -pw:MyPw -Title:"New entry title"
```
--------------------------------
### Malicious URL with Command Execution Placeholder
Source: https://keepass.info/help/base/security.html
This URL example shows how a malicious URL can be used to execute a command-line program, such as Calc.exe, on the user's system.
```plaintext
https://example.com/{CMD:/Calc.exe/W=0/}
```
--------------------------------
### Simple KeePass 2.x Key Provider Plugin
Source: https://keepass.info/help/v2_dev/plg_keyprov.html
A complete and compilable C# source code example for a basic key provider plugin for KeePass 2.x. This plugin demonstrates registration and termination within the KeePass plugin host.
```csharp
using System;
using KeePass.Plugins;
using KeePassLib.Keys;
namespace KeyProviderTest
{
public sealed class KeyProviderTestExt : Plugin
{
private IPluginHost m_host = null;
private SampleKeyProvider m_prov = new SampleKeyProvider();
public override bool Initialize(IPluginHost host)
{
m_host = host;
m_host.KeyProviderPool.Add(m_prov);
return true;
}
public override void Terminate()
{
m_host.KeyProviderPool.Remove(m_prov);
}
}
public sealed class SampleKeyProvider : KeyProvider
{
public override string Name
{
get { return "Sample Key Provider"; }
}
public override byte[] GetKey(KeyProviderQueryContext ctx)
{
// Return a sample key. In a real key provider plugin, the key
// would be retrieved from smart card, USB device, ...
return new byte[]{ 2, 3, 5, 7, 11, 13 };
}
}
}
```
--------------------------------
### Interactive Program Notice for GNU GPL
Source: https://keepass.info/help/v2/license.html
A short notice to display when an interactive program starts, informing users about its free software status and warranty limitations.
```text
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'. This is free software, and you are welcome
to redistribute it under certain conditions; type `show c'
for details.
```
--------------------------------
### Run Multiple Programs in Parallel
Source: https://keepass.info/help/kb/faq.html
Execute multiple programs in parallel using the 'START' command within cmd.exe. Programs are launched independently.
```URL
cmd://%COMSPEC% /C "START %WINDIR%\Notepad.exe & START %WINDIR%\Explorer.exe"
```
--------------------------------
### Run KeePass on Linux/Unix-like Systems
Source: https://keepass.info/help/v2/setup.html
Execute the KeePass portable version using the Mono runtime. Ensure Mono is installed and the path to KeePass.exe is correct.
```bash
mono KeePass.exe
```
--------------------------------
### Open Database with Path
Source: https://keepass.info/help/base/cmdline.html
Specify the database file path to open it immediately on startup. Enclose paths with spaces in quotes.
```bash
KeePass.exe "C:\My Documents\Database.kdbx"
```
--------------------------------
### Specify Key File with -keyfile:
Source: https://keepass.info/help/base/cmdline.html
Provide the path to a key file or key provider plugin using the -keyfile: parameter. Quote paths containing whitespace.
```bash
KeePass.exe -keyfile:D:\pwsafe.key
```
--------------------------------
### Executing a KPS Script File
Source: https://keepass.info/help/v2_dev/scr_kps_index.html
Demonstrates the command-line syntax for executing a KPS script file using KPScript.exe. Ensure the file has a .kps extension.
```bash
KPScript.exe C:\KeePass\MyScriptFile.kps
```
--------------------------------
### Executing KPUInput Plugin Script
Source: https://keepass.info/help/kb/autotype_wayland.html
This snippet shows how to make the KPUInputN.sh script executable and then run it to generate the KPUInputN.so plugin file.
```bash
chmod +x KPUInputN.sh; ./KPUInputN.sh
```
--------------------------------
### Inserting User Name into URL Field
Source: https://keepass.info/help/base/fieldrefs.html
An example demonstrating how to insert the user name from an entry titled 'Example Website' into the URL field of another entry. This is useful for dynamically populating login URLs.
```plaintext
https://forum.example.com/?user={REF:U@T:Example Website}
```
--------------------------------
### CSV Group Import Example
Source: https://keepass.info/help/kb/imp_csv.html
Illustrates importing entries into specific groups using a 'Group' field. The group path is defined in a single column, with nodes separated by a forward slash. This example shows entries being placed into 'Internet/EMail' and 'Internet/Homebanking' subgroups.
```csv
"Internet/EMail","Sample Entry 1","tom@example.com","12345"
"Internet/Homebanking","Sample Entry 2","Michael","TopSecret"
```
--------------------------------
### Execute Command Line with Notepad
Source: https://keepass.info/help/base/autourl.html
Use the 'cmd://' protocol to execute command lines, including passing arguments to applications. Paths with spaces must be enclosed in double quotes.
```plaintext
cmd://C:\\Windows\\Notepad.exe C:\\Test\\MyTestFile.txt
```
--------------------------------
### Run Command Line with {CMD}
Source: https://keepass.info/help/base/placeholders.html
The {CMD} placeholder executes a specified command line. It supports options for the execution method (ShellExecute or CreateProcess), handling standard output, and waiting for termination. Ensure paths with spaces are quoted.
```plaintext
{CMD:/Notepad.exe/W=0/}
```
```plaintext
{CMD:!Notepad.exe!W=0!}
```
--------------------------------
### Enforced Configuration with MergeContentMode
Source: https://keepass.info/help/kb/config_enf.html
An example of an enforced configuration file specifying 'Replace' mode for merging.
```xml
true
```
--------------------------------
### Executing a Post-Build Command to Copy Files
Source: https://keepass.info/help/v2_dev/plg_index.html
Embed a post-build command using `--plgx-build-post:` to copy files from the temporary directory to the cache directory. Paths with placeholders should be quoted.
```bash
KeePass.exe --plgx-create C:\YourPluginDir --plgx-build-post:"cmd /c COPY \"{PLGX_TEMP_DIR}MyFile.txt\" \"{PLGX_CACHE_DIR}MyFile.txt\""
```
--------------------------------
### Basic CSV Import Example
Source: https://keepass.info/help/kb/imp_csv.html
This example demonstrates a basic CSV file structure for importing entries into KeePass. Ensure the field separator is set to ',', the record separator to newline, and the text qualifier to '"'. Activate the escape character option if your data contains escaped characters like '\'. Consider ignoring the first row if it contains only headers.
```csv
"Account","Login Name","Password","Web Site","Comments"
"Sample Entry 1","User Name","Password","https://keepass.info/","Note"
"Sample Entry 2","tom@example.com","Tom'sPass",,"This is a sample note"
"Sample Entry 3","Fred","Password\,with\\escaped\"characters",,
"Sample Entry 4","Michael321","12345","https://keepass.info/",
```
--------------------------------
### Add New Entry with Title, Username, Password, and URL
Source: https://keepass.info/help/v2_dev/scr_sc_index.html
Adds a new entry to the database, specifying the title, username, password, and URL. This demonstrates providing multiple details for a new entry.
```bash
KPScript -c:AddEntry "C:\\KeePass\\MyDb.kdbx" -pw:MyPw -Title:SomeWebsite -UserName:Don -Password:pao5j3eg -URL:https://example.com/
```
--------------------------------
### Preselect Key File for KeePass Database
Source: https://keepass.info/help/base/cmdline.html
Opens a KeePass database, preselecting a key file but still prompting for the password.
```bash
KeePass.exe "C:\My Documents\DatabaseWithTwo.kdbx" -preselect:F:\pwsafe.key
```
--------------------------------
### Get URL Override
Source: https://keepass.info/help/base/cmdline.html
Saves the current override for all entry URLs to a temporary file in INI format.
```bash
KeePass.exe -get-urloverride
```
--------------------------------
### Example of MergeNodeMode 'Remove'
Source: https://keepass.info/help/kb/config_enf.html
Demonstrates how setting MergeNodeMode to 'Remove' in the enforced configuration removes the corresponding node from the user configuration.
```xml
-
Example_A
21
-
Example_B
22
```
```xml
-
Example_A
```
```xml
-
Example_B
22
```
--------------------------------
### Creating a PLGX Plugin with Prerequisites
Source: https://keepass.info/help/v2_dev/plg_index.html
Use the `--plgx-create` command with prerequisite options for KeePass version and .NET Framework. KeePass will display an error if prerequisites are not met.
```bash
KeePass.exe --plgx-create C:\YourPluginDir --plgx-prereq-kp:2.09 --plgx-prereq-net:3.5
```
--------------------------------
### Auto-Type Sequence with Text
Source: https://keepass.info/help/base/autotype.html
An example of an auto-type sequence that includes literal text to be typed, along with placeholders and special key codes.
```plaintext
{USERNAME}{TAB}Some text to be sent!{ENTER}
```
--------------------------------
### Referencing by UUID in KeePass
Source: https://keepass.info/help/base/fieldrefs.html
An example of referencing a password field using the unique UUID of the target entry. This ensures unambiguous referencing.
```plaintext
{REF:P@I:46C9B1FFBD4ABC4BBB260C6190BAD20C}
```
--------------------------------
### Example Auto-Type String
Source: https://keepass.info/help/v2/autotype_obfuscation.html
This string demonstrates a typical sequence sent by KeePass to another application, including email, tabs, password, and special keys.
```plaintext
mymail@myprovider.com{TAB}MyTopSecretPassword{TAB} {TAB}{ENTER}
```
--------------------------------
### Basic URL with Username and Password Placeholders
Source: https://keepass.info/help/base/autourl.html
Use {USERNAME} and {PASSWORD} placeholders in a URL to automatically insert credentials from the entry's fields when the URL is executed.
```url
https://www.example.com/default.php?user={USERNAME}&pass={PASSWORD}
```
--------------------------------
### Preselect Key File with -preselect:
Source: https://keepass.info/help/base/cmdline.html
Preselect a key file or provider in the master key dialog without prompting for it. This option activates the key file/provider and sets focus to the password field.
```bash
KeePass.exe "C:\My Documents\Database.kdbx" -preselect:C:\pwsafe.key
```
--------------------------------
### Launching Specific Browsers with Placeholders
Source: https://keepass.info/help/base/autourl.html
Utilize browser-specific placeholders like {EDGE}, {FIREFOX}, etc., to open a given URL in a particular browser. The placeholder is replaced by the browser's executable path.
```url
cmd://{EDGE} "https://www.example.com/"
```
```url
cmd://{FIREFOX} "https://www.example.com/"
```
```url
cmd://{GOOGLECHROME} "https://www.example.com/"
```
```url
cmd://{INTERNETEXPLORER} "https://www.example.com/"
```
```url
cmd://{OPERA} "https://www.example.com/"
```
```url
cmd://{SAFARI} "https://www.example.com/"
```