Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Default key-disk or key-file on logging in?

Help
2006-04-20
2012-11-19
  • Is it possible to set an option look in say f: drive for the key-file as a default?

    I have my key file on a removable drive.  Ideally I would like KeePass to remember where to look for the  key on logging into KeePass so that I don't have to check the box and select the correct drive every time I login or unlock it.

     
    • Paul
      Paul
      2006-04-20

      KeePass will not search or remember the location, but you can set it on the command line.
      Try this batch file to open KeePass.

      for %%x in (D E F G H I J) do if exist %%x:\pwsafe.key set _kpkey=%%x
      KeePass.exe mydatabase.kdb -keyfile:%_kpkey%:\pwsafe.key

      You will need to set the location of KeePass and the database obviously.

      cheers, Paul

       
    • Thank you Paul.

      Yes the command line options seem to be the way to go.  (I had been hoping to set an option in the ini file.) I had found the command line option "-preselect:" which seems to do what I am aiming for .  However although it works perfectly on the initial launch it does not work subsequently if the batch file is run while KeePass is already running or if the workspace is locked.  In these cases it will not preselect the key file.

      The workaround I've found (for XP at least) is to use taskkill before restarting the application.  So my batch file looks like the following:

      ------------------------------
      taskkill /im keepass.exe
      start c:\temp\kptest\keepass.exe c:\temp\kptest\test.kdb -preselect:c:\temp\kptest\test.key
      ------------------------------

      Thank you for your time.

       
    • Actually the batch file idea only works if I run the batch from the command line (nb: not if I have the option 'Close button [X] minimizes window' set).  If I have it as a windows shortcut it will kill KeePass the first time it is run but not restart KeePass.  I have to run it a second time for it to work. 

      Would anyone know if this is because the second line runs too quickly and the taskkill hasn't finished?  Is it possible to introduce a line to wait until taskkill has finished before starting KeePass again?

      Thanks for your time.

       
    • Paul
      Paul
      2006-04-21

      Preselect only uses a drive letter as an argument. If you want to specify the file directory/name you need -keyfile.

      You should not need to kill KeePass. As long as it is set to single instance, any command line is passed to KeePass and interpreted as if it were starting afresh.

      cheers, Paul

       
    • SF User·
      SF User·
      2006-04-27

      You can also create a shortcut with a target of:

      f:\comsec-pgm\KeePass.exe  f:\MydBPath\path\mykee.kdb -preselect:f:\myKeyFileName.myext

      Start In:
      \

      Run:
      Normal Window

       
    • The same problem remains - if you run it a second time the -preselect option is ignored.  (I have it to run a single instance only.) (Specifying the path with the -preselect option is possible.)

      Any ideas how to wait for the taskkill to finish before restarting the program?

      Thanks for your time.

       
    • Paul
      Paul
      2006-04-28

      Taskkill doesn't really work. If the program want's you to do something (save the file), taskkill incorrectly reports success.

      The command line should work, it does for me, but you do need to use -keyfile if you want the database to open automatically.

      The -preselect option does seem to be flakey, a bug report is in order, with as much detail as you can.

      (see https://sourceforge.net/forum/forum.php?thread_id=1413433&forum_id=329220\).

      cheers, Paul