Request: Partial-URL placeholders

Brad Mace
  • Brad Mace

    Brad Mace - 2012-05-23

    There are cases where being able to reference only part of a URL would be very helpful. I'd like to see






    placeholders to allow greater flexibility.

    For example, SQL Server Management Studio takes the host and database as separate arguments. I'd like to be able to specify the URL as "mssql://server/database" and then reference


    to get "server" and


    to get "database". This allows the schema override

    cmd://ssmsee.exe -S {URL:HOST} -d {URL:PATH} -U {USERNAME} -P {PASSWORD}

    to work nicely.

  • Dominik Reichl

    Dominik Reichl - 2012-05-25

    I've now added {URL:SCM}, {URL:HOST}, {URL:PORT}, {URL:PATH} and {URL:QUERY}.

    Here's the latest development snapshot for testing:

    Best regards

  • Brad Mace

    Brad Mace - 2012-05-25

    That was fast! While the leading slash is indeed part of the path, SQL Management Studio doesn't like it in the database parameter. My suspicion is that most often if the URL needs to be split, the leading slash will not be wanted, but there are probably exceptions. Perhaps an additional {URL:RELPATH} without the leading slash would be a good way to solve this?

  • Dominik Reichl

    Dominik Reichl - 2012-05-25

    What happens when you prepend a dot to the placeholder, i.e. use ".{URL:PATH}"?

  • Frank Grieger

    Frank Grieger - 2013-09-05

    Hi there,

    I found this topic because I was experimenting with the same idea. I'd really like to use these URL-parts, but I also found the leading slashes (in case of {URL:PATH}) or questionmarks (in case of {URL:QUERY}) to be a problem for my task.
    (to your question: adding a dot didn't change the behavoir in my case)

    In particular case i am using the keepass URL to start a SAPGUI using the command sapshcut. This command has various options to specify where and how to connect and to use a specific user/pw. Here is my currently used string (defined as a URL Scheme Override named 'sap') and this contains a few workarounds, which could be replaced in a nice way using these URL parts.

    cmd://"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe" -system={Title} -client={S:Mandt} -user={UserName} -pw={Password} {Notes}

    If possible i'd like to replace this by:

    cmd://"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe" -system={URL:HOST} -client={URL:PATH} -user={UserName} -pw={Password} {URL:QUERY}
    - replacing S:Mandt saves me this additional custom string filed
    - replacing Title ans Notes frees these fields for their intended purpose to contain Information, not Values (the Notes field is used for adding addtional parameters to sapshcut, for example '-command=STMS' to start this transaktion right afer loging in.

    My URL would look like this example:

    best regards Frank

  • Frank Grieger

    Frank Grieger - 2013-09-05

    as a sideinfo:
    I also tried to use the {URL:PORT} to store any of those values, but this seems to only accept numbers and seems to cut these numbers mathematically (so leading zeros are stripped) - also I was unable to use it for "000" - this was interpreted as "-1".

  • Dominik Reichl

    Dominik Reichl - 2013-09-05

    I recommend to use the powerful T-REPLACE-RX placeholder for performing string manipulations. This placeholder searches and replaces text using a regular expression; details can be found in the help:
    This placeholder has been introduced in KeePass 2.23.

    Example 1. To remove leading slashes from {URL:PATH}, you could use:


    Example 2. To extract the part right of the '?' from the URL 'sap://SID/000?-command=STMS', you could use:


    Best regards,

  • Frank Grieger

    Frank Grieger - 2013-09-06


    you have a really great reaction time, thanks for that :)

    I've tested your examples - I really like the idea of regexp in KeePass, and I tryed these even before I posted yesterday (not sure about my exact syntax yesterday...). So again today, but for some reason the program is not evaluating the T-REPLACE-RX command in the OverrideURL.

    I created the Scheme 'testie' with the OverrideURL (to get the complete command output):

    cmd://"C:\Windows\System32\cmd.exe" /k echo -system={URL:HOST} -client={T-REPLACE-RX:!{URL:PATH}!/(.*)!$1!} -user={UserName} {T-REPLACE-RX:#{URL}#.*\?(.*)#$1#}

    My URL used is:


    But this is the output I get:

    -system=sid -client={T-REPLACE-RX:!/000!/(.*)!$1!} -user=FGRIEGER_TEST {T-REPLACE-RX:#testie://SID/000?-command=STMS#.*\?(.*)#$1#}

    ==> so the {URL} respectivly {URL:HOST} or {URL:PATH} are evaluated and written into the command string, but the command {T-REPLACE-RX:...} is not.

    Any idea?

    Last edit: Frank Grieger 2013-09-06
  • Dominik Reichl

    Dominik Reichl - 2013-09-06

    Your definitions are correct and do work (I've tested it; it outputs '-system=sid -client=000 -user= -command=STMS' as expected).

    Make sure that you're using KeePass 2.23. The T-REPLACE-RX placeholder doesn't exist in earlier versions.

    Best regards,

  • Frank Grieger

    Frank Grieger - 2013-09-09

    Yep thank you - i had mixed up the 2.23 portable version, while having the 2.21 installation version still active. I run the installation for 2.23 now and it's working as you described.
    Thanks a lot.

    regards Frank


Log in to post a comment.