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 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
<!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="URL Field - 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>URL Field - 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_enhanced_browsing.png" alt="" /></td>
<td><h1>URL Field</h1>
<p>The URL field supports various special protocols and placeholders.</p></td>
</tr></table>
<ul>
<li><a href="#stdcp">Standard Capabilities</a></li>
<li><a href="#cmdln">Executing Command Lines</a></li>
<li><a href="#subst">Placeholders</a></li>
<li><a href="#override">Changing the URL Handler (URL Override)</a></li>
</ul>
Usage Tips & Tricks:
<ul>
<li><a href="#rdpts">Starting RDP/TS Sessions (Remote Desktop / Terminal Server Connection)</a></li>
<li><a href="#builtin">Executing Built-In Shell Commands</a></li>
</ul>
<br />
<a name="stdcp"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_ascii.png" alt="" />
Standard Capabilities</h2>
<p>The URL field can execute any valid URL for which a protocol handler is defined.
On most systems at least the <code>http://</code>, <code>https://</code>,
<code>ftp://</code> and <code>mailto:</code> protocols are defined.
KeePass supports all protocols that Windows supports.</p>
<p>For example, if you globally (i.e. using the Windows Explorer) register PuTTY for <code>ssh://</code> URLs,
KeePass will automatically use PuTTY for <code>ssh://</code> URLs, too.</p>
<br />
<a name="cmdln"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="" />
Executing Command Lines</h2>
<p>Instead of a URL, you can also execute command lines using the URL field.
To tell KeePass that the line you entered
is a command line, prefix it using <code>cmd://</code>. For example if you would like to execute
Notepad, your URL could look like this:</p>
<pre>cmd://C:\Windows\Notepad.exe C:\Test\MyTestFile.txt</pre>
<p>The virtual <code>cmd://</code> protocol also supports parameters for executable
files, in contrast to
the <code>file://</code> protocol. This was the main reason why <code>cmd://</code>
was introduced; with <code>file://</code> you
aren't able to pass any parameters to started applications. Use the <code>cmd://</code>
protocol instead.</p>
<p>The paths for the <code>cmd://</code> protocol don't need to be encoded. For example,
you do not have to replace space characters by <code>%20</code>, as it is normally
required for other URLs. KeePass just cuts away the <code>cmd://</code> virtual
protocol prefix and passes the remaining command line to the system.</p>
<p>If the file path contains spaces, you must enclose it in quotes (").</p>
<p><b>Environment Variables:</b><br />
System environment variables are supported.
The name of the variable must be enclosed in '<code>%</code>' characters.
For example <code>%TEMP%</code> is replaced by the user's temporary path.</p>
<p><b>UNC Paths:</b><br />
Windows-style UNC paths (starting with <code>\\</code>) are directly
supported, i.e. do not need to be prefixed with <code>cmd://</code>.</p>
<p><b>Double Quotes (<code>"</code>) and Backslashes (<code>\</code>):</b><br />
There are multiple rule sets for parsing command lines
<!-- https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow -->
(<a href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow"
target="_blank"><code>SHELLEXECUTEINFOW</code> structure</a>,
<!-- https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw -->
<a href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw"
target="_blank"><code>CommandLineToArgvW</code> function</a>,
<!-- https://docs.microsoft.com/en-us/cpp/cpp/parsing-cpp-command-line-arguments -->
<!-- https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args -->
<a href="https://learn.microsoft.com/en-us/cpp/cpp/main-function-command-line-args"
target="_blank"><code>main</code> function and command line arguments</a>, etc.).
These rule sets are contradictory; command lines are interpreted differently.
For example, in the <code>SHELLEXECUTEINFOW</code> structure documentation,
backslashes have no special meaning, whereas the
<code>CommandLineToArgvW</code> function sometimes interprets a backslash
as an escape character.
Another example: <code>A"""B C"""D</code> is
interpreted as <em>one</em> argument (namely <code>A"B C"D</code>)
by the Microsoft C/C++ startup code (<code>main</code> function), whereas the
<code>CommandLineToArgvW</code> function returns <em>two</em> arguments
(namely <code>A"B</code> and <code>C"D</code>).
KeePass cannot know how the executed application will interpret its
command line, and there is no command line encoding that is
interpreted as intended by all applications.
Therefore, we recommend:</p>
<ul>
<li>Use double quotes (") only to indicate the start and the end of
the file path or of an argument. Do not use a quote in data that
requires encoding. For example, if your command line contains a
<code>{PASSWORD}</code> <a href="placeholders.html">placeholder</a>,
the password should not contain a quote.</li>
<li>Use a backslash only when the next character is not a quote,
i.e. avoid <code>\"</code>.
Especially, avoid data ending with a backslash if a quote follows on
the command line. For example, if the command line contains an
argument like <code>-pw:"{PASSWORD}"</code>, the password should
not end with a backslash, because otherwise the placeholder replacement
results in the problematic <code>\"</code> sequence.</li>
</ul>
<p><b>Unix-like Systems:</b><br />
On Unix-like systems, KeePass assumes that double quotes (<code>"</code>)
and backslashes (<code>\</code>) must be encoded.
Furthermore, KeePass assumes that single quotes (<code>'</code>)
only occur in contexts where they must not be encoded (e.g. within
double quotes). So, if any of your arguments may contain a single quote,
you have to ensure that it occurs within such a context.
On Windows, this is irrelevant, as single quotes do not have a special meaning here.</p>
<br />
<a name="subst"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_ascii.png" alt="" />
Placeholders</h2>
<p>In the URL field, you can use several placeholders that will get automatically replaced
when the URL is executed. For example:</p>
<pre>https://www.example.com/default.php?user={USERNAME}&pass={PASSWORD}</pre>
<p>For this entry, KeePass will replace {USERNAME} by the data of the username field and {PASSWORD}
by the data in the password field when you execute the link.</p>
<p>For a complete list of supported placeholders, see the page
<a href="placeholders.html">Placeholders</a>.</p>
<p>Also note that the special placeholders are supported, too. For example,
the <code>{APPDIR}</code> placeholder is replaced by the application
directory path of the currently running KeePass instance. It's the absolute path of the
directory containing the KeePass executable, without a trailing backslash.
If you would like to start a new KeePass instance, you could set the URL to:</p>
<pre>cmd://"{APPDIR}\KeePass.exe"</pre>
<p>To use different browsers for entries, you can use URLs like the following:<br />
<code>cmd://{INTERNETEXPLORER} "https://www.example.com/"</code><br />
<code>cmd://{FIREFOX} "https://www.example.com/"</code><br />
<code>cmd://{OPERA} "https://www.example.com/"</code><br />
<code>cmd://{GOOGLECHROME} "https://www.example.com/"</code><br />
<code>cmd://{SAFARI} "https://www.example.com/"</code><br />
The browser placeholder will be replaced by the browser's executable path (if the
browser is installed).</p>
<br />
<a name="override"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_ascii.png" alt="" />
Changing the URL Handler (URL Override)</h2>
<br />
<p>The URL field behavior can be overridden individually for each entry
using the field 'Override URL' (tab 'Properties' in the entry dialog).
This allows you to execute a specific URL, while still using the URL
field to (only) store data.
When double-clicking the URL field of the entry in the main window, the
specified command line (in the URL override field) will be run.</p>
<p><b>Using a different browser:</b><br />
If your default browser is Firefox and you want to open a specific site with
Internet Explorer, specify the following in the URL override field:</p>
<p><code>cmd://{INTERNETEXPLORER} "{URL}"</code></p>
<p>KeePass will open Internet Explorer and pass the data from the URL field
as the parameter. This uses a <a href="#subst">placeholder</a> to find Internet
Explorer.</p>
<p><b>Globally changing the URL behavior:</b><br />
If you want to change the <i>default</i> URL action for a URL scheme
(e.g. <code>http://</code>, <code>https://</code> or <code>ftp://</code>),
you can define a URL scheme override
in 'Tools' → 'Options' → tab 'Integration' → 'URL Overrides'.
This for example allows to specify a browser as default for websites
(in the dialog you can find several overrides for browsers like Internet Explorer,
Mozilla Firefox, Opera and Google Chrome).</p>
<p>URL scheme overrides can also be used to define new protocols. For example,
if you want to define a protocol <code>kdbx://</code> that opens another KeePass database,
specify the following as override for the <code>kdbx</code> scheme (on Windows):<br />
<code>cmd://"{APPDIR}\KeePass.exe" "{BASE:RMVSCM}" -pw-enc:"{PASSWORD_ENC}"</code><br />
On Unix-like systems (Mono):<br />
<code>cmd://mono "{APPDIR}/KeePass.exe" "{BASE:RMVSCM}" -pw-enc:"{PASSWORD_ENC}"</code><br />
If an entry now has a URL looking like <code>kdbx://<i>PathToYourDatabase.kdbx</i></code>
and the master password for this database in the password field,
double-clicking the URL of the entry in the main window opens the other database.
The <code>-pw-enc</code> <a href="cmdline.html">command line</a> parameter and
the <a href="placeholders.html#passwordenc"><code>{PASSWORD_ENC}</code></a> placeholder
allow passing the master password of the other database in encrypted form,
i.e. process monitors and similar utilities aren't be able to read the master password.</p>
<br /><br />
<a name="rdpts"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="" />
Starting RDP/TS Sessions</h2>
<p>You can use the URL field of entries and the virtual <code>cmd://</code>
protocol to start remote desktop connections.</p>
<p>For this, enter the following in the URL field of an entry:</p>
<pre>cmd://mstsc.exe</pre>
<p>When you now double-click the URL field of the entry in the main window, a
Windows remote desktop connection is initiated.</p>
<p>MSTSC is the Windows terminal server connection program (remote desktop connection).
You can pass a path to an existing RDP file to the program to open it. For example,
the following URL opens the specified RDP file:</p>
<pre>cmd://mstsc.exe "C:\My Files\Connection.rdp"</pre>
<p>MSTSC also supports several command line options:</p>
<ul>
<li><b>/v:<Server[:Port]></b><br />Defines the terminal server to connect to.</li>
<li><b>/console</b><br />Connects to the terminal session of the server.</li>
<li><b>/f</b><br />Starts the client in full screen mode.</li>
<li><b>/w:<Width></b><br />Defines the width of the remote desktop screen.</li>
<li><b>/h:<Height></b><br />Defines the height of the remote desktop screen.</li>
<li><b>/edit</b><br />Opens the specified RDP file for editing.</li>
<li><b>/migrate</b><br />Migrates old connection files to new RDP files.</li>
</ul>
<br />
<a name="builtin"></a>
<h2 class="sectiontitle"><img src="../images/b16x16_openterm.png" alt="" />
Executing Built-In Shell Commands</h2>
<p>The URL field can be used to start applications/documents and URLs.
If you want to execute a built-in shell command, like <code>COPY</code> for
example, this however doesn't work directly, because there is no <code>COPY.EXE</code>
(in Windows 9x times there actually was one, but on all modern Windows operating
systems these commands are built-in to the command line window).</p>
<p>In order to execute built-in shell commands, you need to pass them to the
command line interpreter <code>cmd.exe</code>.</p>
<p>For the <code>COPY</code> command you would specify <code>cmd.exe</code>
as executable file and <code>/C COPY from to</code> as arguments (where
'<code>from</code>' and '<code>to</code>' are paths). The <code>/C</code>
parameter tells <code>cmd.exe</code> to execute the command line that
follows.</p>
<p>In the URL field, your URL would look like the following:<br />
<code>cmd://cmd.exe /C COPY from to</code><br />
In other locations, like command lines in the trigger system,
you can leave out the <code>cmd://</code> URL prefix.</p>
</body></html>
|