10

I have configured KeePass to Lock workspace when computer is about to be suspended (under Options→Security), which ensures my passwords are protected when my Windows 7 system sleeps or hibernates. But each time I restore my system from sleep or hibernation, my passwords are consequently locked and I must right-click KeePass' tray icon, select Unlock Workspace, and enter my database master key.

Is there a way to have KeePass prompt for my key automatically in this situation?

14

(I answer my own question):

I can find no way to configure KeePass itself to Prompt for master password when restored, so here is a workaround based on this superuser question:

Create and save a new Windows Scheduled Task:

  1. Start Task Scheduler: WinAdministrative Tools→Task Scheduler, or Win+R and enter taskschd.msc
  2. In Task Scheduler, Action→Create Task
  3. In Create Task's General tab, name the task Run KeePass at unlock
  4. In Create Task's Triggers tab, click New... then for Begin the task: select On workstation unlock and click OK
  5. In Create Task's Actions tab, click New... then in the Program/script field enter "C:\WINDOWS\System32\cmd.exe" and in the Add arguments (optional) field enter /c start "" "C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe" (or the location of your KeePass binary)
  6. Click OK in Create Task to save the task, then close the Task Scheduler window.

Now when you unlock your system, Task Scheduler will execute KeePass, which will gain focus and prompt you for your Master Password. If you have KeePass configured to Minimize main window after opening a database (under Options→Interface), your KeePass windows will also minimize after you have successfully entered your Master Password.

  • 3
    Out of curiosity, is there a reason why you can't enter the path to KeePass in the Program/script field directly, instead of as an argument to cmd.exe? – Kodos Johnson Jan 12 at 1:59
  • @KodosJohnson, initially I entered the path as you describe. That caused KeePass to prompt me when I restored my Windows, but KeePass' prompt did not have focus, so I needed to click on the Master Password input field before typing. The use of cmd.exe eliminates this need. – CODE-REaD Jan 12 at 16:35
  • Since writing this answer, I notice on my Windows 7 Pro/64/SP1 system that sometimes KeePass does not gain focus when I restore my session. So I am testing revised instructions for step 5 above: In the Add arguments (optional) field enter /c start "" <location of your KeePass database file>. To find the location of your KeePass database file, open the main KeePass window after logging in to KeePass; the file location should show in KeePass' window title. Once I'm confident that this is an improvement I will update my answer with it. Meanwhile, I'll watch here for comments. – CODE-REaD 11 hours ago

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.