I took the task of encrypting all of my drives with Truecrypt a while back and it became very apparent that it was going to be a pain to manually mount the drives every time I logged into my Windows workstation. I didn’t want to load them at boot time like some users choose to do as I chose the hidden partition option when initially creating them. I thought if I housed the batch script on a flash drive and that information never got copied but only ran from the flash drive then I could keep the script on the USB thumb drive and insert and run when I was ready to mount the Truecrypt drives.
For more information on command line usage from Truecrypts site:
http://www.truecrypt.org/docs/?s=command-line-usage
I will throw in some examples of what a typical .bat file would look like in regard to Trucrypt and dissect it piece at a time so you can better understand it.
This is what is contained in my mountruecrypt.bat file housed on my thumbdrive.
REM Mounting HDD1_DATASTORE_1
“c:\program files\truecrypt\truecrypt.exe” /volume “\Device\Harddisk3\Partition2” /letter w /password “passwordinstertedhere” /quit
So REM is a command to display output to the user so in this case REM displays “Mounting HDD1_DATASTORE_1”
to me when I initially click on the script and run it.
REM Mounting HDD1_DATASTORE_1
The next part in quotations is where the truecrypt installation and executable is stored. I have mine stored within the quotations.
“c:\program files\truecrypt\truecrypt.exe”
The next piece is what volume I want to mount. You can find out by clicking on devices within the Truecrypt program. I used the /volume switch or you can just use /v.
My example:
/volume “\Device\Harddisk3\Partition2”
Your example:
/volume “entervolumenamehere” or /v “entervolumenamehere”
Next we have what drive you want to mount it as you can use /letter or /l as the switch so:
My example:
/letter w
Your example:
/l yourdriveletterhere or /letter yourdriveletterhere
Next up is the password which is /password or /p for the switch.
My example where passwordinsteredhere is the password:
/password “passwordinstertedhere”
Your example:
/password “yourpassword” or /p “yourpassword”
NOTE: In batch scripts it doesn’t like special characters because it wants to treat your “” as a special character so I made sure that my particular passwords are 256 bit strength in length but only consist of uppercase and lowercase letters and numbers. I’m sure there is probably a way to do this to account for special characters but for the purpose of this tutorial I am keeping it simple for the average user. If you do know how to do this please comment so I can learn something 🙂
The last switch is for a silent mode it basically runs the command and then exits to the background i.e. system tray. You don’t have to do this but this way the Truecrypt window will not pop up so in my opinion its more streamlined and clean.
You can use /quit or /q
After you are done writing your script make sure it has a .bat extension as Windows will recognize that as a batch script. Please let me know if you have any questions. For security purposes I always recommend never leaving this script anywhere on your drives/desktop/workstation rather on a separate device as it will contain the password of your Truecrypt drive. As always drop me a comment if you have any questions.
-Digital Hoarder