I have most of my partitions encrypted and saved as favorites in Truecrypt. They can be mounted silently with
TrueCrypt.exe /auto favorites /quit. This will only pop up the password window, mount the volumes when password is correct and quit afterwards. But since I'm using KeePass and software plus database are stored on encrypted volumes, I wanted to have a one click solution. Here's the code. I've splitted it into two files. One will open TrueCrypt dialog, the other will start KeePass and open the database with the given keyfile. Within
:startprograms any program can be started.
REM truecrypt.bat REM Truecrypt mount and launch file @ECHO OFF SET tcexec="%PROGRAMFILES%\TrueCrypt\TrueCrypt.exe" REM Mount favorite volumes %tcexec% /auto favorites /quit echo %ERRORLEVEL% if ERRORLEVEL 1 GOTO mountfail if ERRORLEVEL 0 GOTO startprograms :startprograms SET kpbat="path\to\keepass-autostart.bat" IF NOT EXIST %kpbat% GOTO kpfail CALL %kpbat% GOTO end :mountfail echo Mount failed GOTO end :kpfail echo keepassAutostart.bat not found GOTO end :end
REM keepass-autostart.bat REM KeePass autostart @ECHO OFF REM Start KeePass and open database SET kpexec="path\to\KeePass.exe" IF NOT EXIST %kpexec% GOTO noexe SET kpkey="path\to\pwd.key" IF NOT EXIST %kpkey% GOTO nokey SET kpdb="path\to\pwd.kdbx" IF NOT EXIST %kpdb% GOTO nodb START "" %kpexec% %kpdb% -keyfile:%kpkey% -minimize GOTO end :noexe echo KeePass.exe not found GOTO end :nokey echo Keyfile not found GOTO end :nodb echo Database not found GOTO end :end
Be sure to have truecrypt.bat on an unencrypted volume.
keepass-autostart.bat can be encrypted.