File: cmdline.html

package info (click to toggle)
keepass2 2.47%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 13,992 kB
  • sloc: cs: 111,053; xml: 5,956; cpp: 308; makefile: 48; sh: 48
file content (230 lines) | stat: -rw-r--r-- 10,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="expires" content="0" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="pragma" content="no-cache" />

	<meta name="author" content="Dominik Reichl" />

	
	

	<meta name="DC.title" content="Command Line Options - KeePass" />
	<meta name="DC.creator" content="Dominik Reichl" />
	<meta name="DC.type" content="Text" />
	<meta name="DC.format" content="text/html" />
	<meta name="DC.language" content="en" />
	<meta name="DC.rights" content="Copyright (C) 2003-2021 Dominik Reichl" />

	<meta name="robots" content="index, follow" />
	<meta name="flattr:id" content="42rykv" />

	<title>Command Line Options - KeePass</title>
	<base target="_self" />
	<link rel="stylesheet" type="text/css" href="../../default.css" />

	
</head>
<body>




<table class="sectionheader"><tr>
<td><img src="../images/b64x64_konsole.png" alt="Command Line" /></td>
<td><h1>Command Line Options</h1>
<p>Command line options to automate KeePass tasks.</p></td>
</tr></table>

<p>You can pass a file path in the command line in order to tell KeePass to open
this file immediately after startup.</p>

<p><!-- Additionally, you can specify the password
and/or key file location for this database. -->Switches can be either prefixed using
a minus (<code>-</code>) or two minus characters (<code>--</code>).
On Windows, a slash (<code>/</code>) is another alternative.
The prefixes are equivalent; it doesn't matter which one you use.</p>

<p><b>Database file.</b>
The database file location is passed as argument. Only one database file is allowed.
If the path contains a space, it must be enclosed in quotes (&quot;).</p>

<p><b>Password.</b>
Passwords can be passed using the <code>-pw:</code> option. In order to
pass 'abc' as password, you would add the following argument to the command line:
<code>-pw:abc</code>. Note that there must be no space between the '<code>:</code>' and the
password. If your password contains a space, you must enclose it in quotes. For
example: <code>-pw:&quot;my secret password&quot;</code>.</p>

<p>Using the <code>-pw:</code> option is not recommended, due to
security reasons (the operating system allows reading the command line
options of other applications).</p>

<p>When passing the <code>-pw-stdin</code> option, KeePass
reads the password from the StdIn stream.
This option is intended for programmatically passing the password to KeePass.
For entering the password by hand, it is recommended to use the
normal master key dialog instead (because in this dialog the password
is hidden by bullets/asterisks and it is encrypted by the process memory
protection).</p>

<p><b>Key file.</b>
For supplying the key file location, the <code>-keyfile:</code> switch
exists. The same rules as above apply, just that you specify the key file location:
<code>-keyfile:D:\pwsafe.key</code>. You also need to quote the value, if it contains
a space, tab or other whitespace characters.</p>

<p><b>Pre-selection.</b>
In order to just pre-select a key file, use the <code>-preselect:</code> option.
For example, if you lock your database with a password <i>and</i> a key file, but
just want to type
in the password (so, without selecting the key file manually), your command line would
look like this:</p>

<pre>KeePass.exe &quot;C:\My Documents\MyDatabase.kdbx&quot; -preselect:C:\pwsafe.key</pre>

<p>KeePass would then show a prompt for the password for the database, but in
the key file list, the <code>C:\pwsafe.key</code> file is selected already. When using the
<code>-preselect:</code> switch, KeePass by default activates the key file switch and
sets the focus to the password edit window.</p>

<p>Note the difference! The <code>-preselect:</code> switch just pre-selects the key file
for you and displays the login prompt. In contrast, the <code>-keyfile:</code> switch
doesn't prompt you for the (maybe missing) password.</p>

<p><b>Other.</b>
The <code>-minimize</code> command line option makes KeePass start up minimized.
This option may not work when KeePass runs on Mono (due to a bug in Mono).</p>

<p>The <code>-auto-type</code> command line option makes other already opened
KeePass instances perform a global auto-type.</p>






Additionally, the <code>-useraccount</code> switch is supported. If specified, the
current user account credentials will be used.<br />
<br />
The <code>-iocredfromrecent</code> switch makes KeePass load file
system credentials (not database key) from the most recently used files list.
Alternatively, the file system credentials can be specified using the
<code>-iousername:</code> and <code>-iopassword:</code> parameters.
The optional <code>-ioiscomplete</code> switch
tells KeePass that the path and file system credentials are complete
(the 'Open URL' dialog will not be displayed then).<br />
<br />
The <code>-pw-enc:</code> parameter is similar to <code>-pw:</code>, but
it requires the password to be encrypted. Encrypted passwords can be
generated using the <a href="placeholders.html#passwordenc"><code>{PASSWORD_ENC}</code></a>
placeholder.<br />
<br />
The <code>-entry-url-open</code> option makes other already opened KeePass instances
search for an entry and open its URL. The entry is identified by its UUID,
which you can pass as <code>-uuid:</code> command line parameter.<br />
<br />
The <code>-auto-type-password</code> option is similar to <code>-auto-type</code>,
but auto-types only the password of a matching entry.
<code>-auto-type-selected</code> performs auto-type for the currently selected entry.<br />
<br />
The <code>-cancel</code> option causes all other KeePass instances to
cancel opening/saving a database file.<br />
<br />
The path of the local <a href="configuration.html">configuration</a> file can be changed
using the <code>-cfg-local:</code> command line parameter.


<p>The order of the arguments is arbitrary.</p>

<br />

<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="Terminal" />
Usage Examples</h2>

<p>Open the database file <i>'C:\My Documents\MyDatabase.kdbx'</i> (KeePass will prompt you
for the password and/or key file location):</p>

<pre>KeePass.exe &quot;C:\My Documents\MyDatabase.kdbx&quot;</pre>

<p>If you got a database that is locked with a password 'abc', you could open it like this:</p>

<pre>KeePass.exe &quot;C:\My Documents\MyDatabaseWithPw.kdbx&quot; -pw:abc</pre>

<p>If your USB stick always mounts to drive F: and you've locked your database with a key file
on the USB stick, you could open your database as follows:</p>

<pre>KeePass.exe &quot;C:\My Documents\MyDatabaseWithFile.kdbx&quot; -keyfile:F:\pwsafe.key</pre>

<p>If you've locked your database using a password <i>and</i> a key file, you can combine
the two switches and open your database as follows:</p>

<pre>KeePass.exe &quot;C:\My Documents\MyDatabaseWithTwo.kdbx&quot; -pw:abc -keyfile:F:\pwsafe.key</pre>

<p>You have locked your database using a password <i>and</i> a key file, but only
want to have the key file pre-selected (i.e. you want to get prompted for the
password), your command line would look like this:</p>

<pre>KeePass.exe &quot;C:\My Documents\MyDatabaseWithTwo.kdbx&quot; -preselect:F:\pwsafe.key</pre>

<br />

<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="Terminal" />
Starting KeePass using a Batch File</h2>

<p>Batch files can be used to start KeePass. Mostly you want to
specify some of the parameters listed above. You can theoretically
simply put the command line (i.e. application path and parameters)
into the batch file, but this is not recommended as the command
window will stay open until KeePass is closed. The following
method is recommended instead:</p>

<pre>START &quot;&quot; KeePass.exe ..\MyDb.kdbx -pw:MySecretPw</pre>

<p>This <code>START</code> command will run KeePass (which opens the
<code>..\MyDb.kdbx</code> file using
<code>MySecretPw</code> as password). KeePass is assumed to be in the same
directory (working directory) as the batch file, otherwise you need to
specify a different path.</p>

<p><code>START</code> executes the given command line and immediately exits,
i.e. it doesn't wait until the application is terminated. Consequently,
the command window will disappear after KeePass has been started.</p>

<p>Please note the two quotes (<code>&quot;</code>) after the
<code>START</code> command. These quotes
are required if the application path contains quotes (in the example
above, the quotes could also be removed).
If you want to learn more about the <code>START</code> command syntax, type
<code>START /?</code> into the command window.</p>

<br />

<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="Terminal" />
Closing/Locking KeePass using a Batch File</h2>

<p>To close all currently running KeePass instances, call
<code>KeePass.exe</code> with the <code>'--exit-all'</code> parameter:</p>

<pre>KeePass.exe --exit-all</pre>

<p>All KeePass windows will attempt to close. If a database has been modified,
KeePass will ask you whether you want to save or not. If you wish to save in
any case (i.e. a forced exit without any confirmation dialog), enable the
<i>'Automatically save database on exit and workspace locking'</i> option
in <i>'Tools' &rarr; 'Options' &rarr; tab 'Advanced'</i>.</p>

<p>The KeePass instance that has been created by the command above is not visible (i.e.
it does not show a main window) and will immediately terminate after sending close
requests to the other instances.</p>

<p>The <code>--lock-all</code> and
<code>--unlock-all</code> command line options lock/unlock the workspaces
of all other KeePass instances.</p>

</body></html>