This project has moved. For the latest updates, please go here.

batch file hangs when running veracrypt

Topics: Technical Issues
Sep 16, 2016 at 4:23 PM
ood day everyone. im using veracrypt to mount and encrypt 2 external hard drives that are swapped weekly. these drives are just used for simple off site backup of certain data. im trying to get veracrypt to auto mount the drives run the backup then dismount the drives but the batch seems to stall as soon as veracrypt is loaded.
this is the basics of the file
@echo off
veracrypt /a

if not exist z: goto nodrives
echo External Backup log > d:\externalbackup.txt
start externalbackup.bat

veracrypt /d
veracrypt /quit

echo no external drives available %date% %time% >> d:\externalbackup.txt



can someone give me some advise on how to make this work. ps. this is running on a win2k3 server. thanks
Sep 17, 2016 at 8:27 AM
Edited Sep 17, 2016 at 8:35 AM
I use 1.17, and almost exclusively perform veracrypt operations using batch files.

I never use the /a switch, so am unfamiliar with its effect in practice. However, I believe it doesn't negate the necessity to specify which volume(s) you are trying to mount. You haven't specified one.
Sep 17, 2016 at 2:55 PM
using the /a switch causes it to auto mount the available drive. there are 2 drives that are swapped out regularly so i cant really designate 1 particular drive. when using the batch file it does mount the drive and its completely accessible just that the batch file stalls out until i close the veracrypt window then it continues to run.
Sep 17, 2016 at 6:27 PM
Edited Sep 17, 2016 at 8:01 PM
I assume you want a password dialogue to appear. What happens if you add /q to your veracrypt /a command?

And is Z: really your next available drive letter? If not, add /l Z too!
Sep 17, 2016 at 11:46 PM
there are 2 drive letters 1 assigned y to 1 drive and 1 assigned z to the other.
Sep 18, 2016 at 8:05 AM
How do you assign the drive letters?
Sep 18, 2016 at 1:42 PM
drive letters were setup when i originally configure the encryption on these drives. if i swap them in and out and just manually launch veracrypt the drives come up in their right order.
Sep 19, 2016 at 12:54 PM
I am totally baffled as to what your setup is, and how your batch file is supposed to do what you want it to do. However, I'll persist trying to help if you wish me to; if you don't, just say, and I'll leave the field clear for others who may be better placed. (I'll not be offended.)

There's two ways this can be progressed:
  • I can keep asking questions so I can understand better what's going on
  • you can give a more detailed explanation of how your external drives were set up and configured in veracrypt (so how the batch file might leverage that setup becomes clearer)
Re the first option:

Will you please answer the question I've already asked: what happens if you add /q to your veracrypt /a command?

And to clarify another question I asked: how do you assign the drive letter(s) to the mounted veracrypt volume(s) when you mount them using your batch file? And what drive letters get assigned to the mounted volumes when you run the batch file?
Sep 20, 2016 at 2:36 PM
Edited Sep 20, 2016 at 2:40 PM
I think I have figured out what your setup is. Veracrypt is set to run when you log on, and you have set up your external drives as 'Favorite Volumes', selecting the 'Mount selected volume when its host device gets connected'. When configuring Favorite Volumes, you can specify the drive letter they mount to, and the PIM. On connection, you should be asked for the password, and the drive automatically mounts.
In which case, the veracrypt /a line in your batch file is redundant; it doesn't mount the drives, they're already mounted, and the line does nothing but launch the GUI, which you have to close before anything else happens. Remove that line, and your file should run.
There are other issues with your batch file eg you don't check for non-existence of y: (for when the alternative drive gets used), but you can easily sort that out.
Sep 20, 2016 at 3:01 PM
veracrypt is not set to run at log on. it is run manually and your correct the 2 external drives are assigned as favorites with their drive letter. the batch file is working fine now just had to place a timeout statement to allow vc enough time to mount the drives. as far as the non-existence of y no worries its done in the true batch i only posted that part as an example. thanks for all the help and suggestions.
Sep 20, 2016 at 6:48 PM
Edited Sep 20, 2016 at 6:49 PM
Still rather puzzled, then. When you say veracrypt is run manually, do you mean, it's run for the first time after logon using your batch file?