TrueCrypt drive letter not available

ccommand linetruecrypt

With c# or a batch file I mount a trueCrypt volume located at

A:\volumeTrueCrypt.tc

With c# I do:

static void Main(string[] args)
{
    var p = Process.Start(
         fileName:@"C:\Program Files\TrueCrypt\TrueCrypt.exe",
         arguments:@"/v a:\volumetruecrypt.tc /lw /a /p truecrypt"
    );
    p.WaitForExit();
}

the alternative is to run the command on the command line as:

C:\Windows\system32>"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v "a:\volumetruecrypt.tc" /lw /a /p truecrypt

Either way I get the error:

enter image description here

Why do I get that error? I was able to run that command the first time. The moment I dismounted the volume and tryied to mount it again I got that error. I know that drive letter W is available because it shows as an available letter on true crypt if I where to open it manually:

enter image description here

If I where then click on the button mount and then type the password truecrypt (truecrypt is the password) then it will successfully mount on drive w. Why I am not able to mount it from the command line!? If I change the drive letter on the command line it works. I want to use the drive W though. In other words executing

 "C:\Program Files\TrueCrypt\TrueCrypt.exe" /v "a:\volumetruecrypt.tc" /lz /a /p truecrypt

will successfully mount that volume on drive z but I do not want to mount it on drive z I want to mount it on drive w. The first time I ran the batch it ran fine. Also if I restart my computer I believe it should work. More info on how to use trueCrypt through the command line can be found at: http://www.truecrypt.org/docs/?s=command-line-usage


Edit

I was also investivating when does this error occures. In order to generate this error you need to follow this steps.

1) execute the command: (note the /q argument at the end for quiet)

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v "a:\volumetruecrypt.tc" /ln /a /p truecrypt /q

"C...TrueCrypt.exe"  = location where trueCrypt is located
/v "path"            = location where volume is located
/n                   = drive letter n
/p truecrypt         = password is "trueCrypt"
/q                   = execute in quiet mode. do not show window

note I am mounting to drive letter n

2) now volume should be mounted.

3) Open trueCrypt and manually dismount that volume (without using command line)

4) Attempt to run the same command line (without the /q so you see the error)

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /v "a:\volumetruecrypt.tc" /ln /a /p truecrypt

5) an error should show up

So the problem ocures when I manually dismount the volume. If I dismount it from the command line I get no errors. But I think this is a bug from trueCrypt

Best Answer

I submitted the bug report to trueCrypt. I found how to replicate the problem though. If you dismount a volume from a program that has no admin rights and then you try to mount the same volume into the same drive latter with a program that has admin rights it does not work. Same thing happens if you do it the otherway arrownd. So in short if you always mount and dismount without admin priviledges you are fine.

In my case I was creating a program that ran with admin privileges. And everytime I executed TrueCrypt.exe I had problems because trueCrypt.exe was running without admin privileges. What I have to do to solve the problem was to change:

enter image description here

now my program and trueCrypt.exe will both run with admin privileges and now I have no problems ;)

Related Question