File: cmdline.html

package info (click to toggle)
keepass2 2.57%2Bdfsg-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 14,520 kB
  • sloc: cs: 120,930; xml: 6,271; cpp: 322; sh: 53; makefile: 49
file content (290 lines) | stat: -rw-r--r-- 12,449 bytes parent folder | download | duplicates (3)
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<!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-2024 Dominik Reichl" />

	<meta name="robots" content="index, follow" />

	<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="" /></td>
<td><h1>Command Line Options</h1>
<p>Command line options to automate KeePass tasks.</p></td>
</tr></table>

<ul>
<li><a href="#gen">General</a></li>
<li><a href="#ex">Usage Examples</a></li>
<li><a href="#batch">Starting KeePass using a Batch File</a></li>
<li><a href="#close">Closing/Locking KeePass using a Batch File</a></li>
<li><a href="#urloverride">Editing URL Overrides (2.x)</a></li>
</ul>

<br />

<a name="gen"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="" />
General</h2>

<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/provider.</b>
For supplying the key file path or the name of the key provider plugin,
the <code>-keyfile:</code> parameter exists.
The same rules as above apply, just that you specify the key file/provider,
e.g. <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>Preselection.</b>
In order to just preselect a key file/provider, 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 could look like this:</p>

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

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

<p>Note the difference! The <code>-preselect:</code> parameter just preselects the key file/provider
in the master key dialog for you. In contrast, the <code>-keyfile:</code> parameter
does not 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.<br />
<br />
If the <code>-debug</code> option is specified, some error messages are
more detailed. Please note that the more detailed error messages may contain
sensitive data (e.g. passwords).


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

<br />

<a name="ex"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="" />
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 preselected (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 />

<a name="batch"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_konsole.png" alt="" />
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 />

<a name="close"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_konsole.png" alt="" />
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>

<br />

<a name="urloverride"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_enhanced_browsing.png" alt="" />
Editing URL Overrides (2.x)</h2>

<p>KeePass 2.x supports the following command line options for editing
<a href="autourl.html#override">URL overrides</a>:</p>

<ul class="withspc">
<li><code>-add-urloverride</code>:<br />
Adds a URL override for a specific scheme. Specify the scheme using the
'<code>-scheme:</code>' command line parameter and the override using the
'<code>-value:</code>' command line parameter.
If the URL override should be enabled, additionally pass the
'<code>-activate</code>' command line option.</li>

<li><code>-remove-urloverride</code>:<br />
Removes a URL override for a specific scheme. Specify the scheme using the
'<code>-scheme:</code>' command line parameter and the override using the
'<code>-value:</code>' command line parameter.</li>

<li><code>-set-urloverride</code>:<br />
The value of this command line parameter (not the
'<code>-value:</code>' command line parameter) is saved as override
for all entry URLs.</li>

<li><code>-get-urloverride</code>:<br />
Saves the current override for all entry URLs to the file
'<code>%TEMP%\KeePass_UrlOverride.tmp</code>' (INI format).</li>

<li><code>-clear-urloverride</code>:<br />
Removes the override for all entry URLs.</li>
</ul>

<p>URL overrides are stored in the
<a href="https://keepass.info/help/kb/config_enf.html" target="_blank">enforced configuration file</a>.
For each of the command line options above except '<code>-get-urloverride</code>',
a User Account Control dialog is displayed, if necessary.</p>

</body></html>