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

Problems at creating a Batch File for VeraCrypt mounting

Topics: Users Discussion
Sep 21, 2015 at 4:28 PM
Edited Sep 21, 2015 at 4:37 PM
Problems at creating a Batch File for VeraCrypt mounting


Hello all,

I used TrueCrypt for many years and thought about moving to VeraCrypt but I get some problems using my old Batch file for mounting my TrueCrypt containers (and even a created VeraCrypt containers doesn't work). Mounting with VeraCrypt itself works fine btw.

Little bit background info:

After a PC start I usally click my Batch file, type in my password and all my four containers will get mounted with drive letters, I set up before in the batch file. The password is the same for all the containers. I found the code of the batch file years ago in the internet and edited it for my personal use and how I wanted it.
With Truecrypt it worked all the time but with VeraCryt I don't get it working.

I guess it is something with the password or the commands for VeraCrypt which maybe differs in some point with the TrueCrypt usage.

Hope to find anyone here who could help me out and tell me what I do wrong.

When I click this batch it asks me for entering password and it doesn't matter if I write it right or wrong, a VeraCrypt hint window pops up with a message which says:
"Error while parsing command line"


To make it more simple I post a short modified example version of my batch file code with only two example containers which should get mounted.

Names of the containers and location are:

1.: f:\Test_TrueCrypt <-- TrueCrypt created container
2.: f:\Test_VeraCrypt <-- VeraCrypt created container

The "Test_TrueCrypt" container shoud get mounted as drive p:\
The "Test_VeraCrypt" container shoud get mounted as drive q:\

Hope I wrote it all understandable and don't mind the german commentary in the batch ;)



Code of my batch file:



@echo off

cls


REM *************************************************************************** *********
REM ** Kleines Batch zum mounten von 2 VeraCrypt-Volumes (auf p:\,q:\ ) mit GLEICHEM Passwort
REM **
REM ** Laufwerksbuchstaben/Anzahl und VeraCrypt-Kommandozeile müssen
REM ** entsprechend angepasst werden
REM **
REM ** Ist ganz hilfreich bei Systemen mit mehreren Benutzern die alle
REM ** die gleichen verschlüsselten Platten benutzen.
REM ** Das heißt der erste der sich nach dem Hochfahren anmeldet
REM ** schaltet die Platten für alle anderen frei.
REM **
REM ** Die Batch entweder in den Autostart einfügen oder (auf eigene Gefahr) über
REM ** [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] einbinden
REM **
REM **
REM ** by Leoric
REM *************************************************************************** *********



REM ****************************************************
REM ** Überprüfen ob schon alle Laufwerke gemountet sind
REM ** Abbruch, wenn dies der Fall ist
REM ** Ansonsten weiter zu Passworteingabe
REM ****************************************************

:main

IF NOT EXIST p:\NUL GOTO pw_input
IF NOT EXIST q:\NUL GOTO pw_input

goto all_connected


REM ****************************************************
REM ** Passwort eingeben (im Klartext)
REM ** Weiter zu Laufwerke verbinden
REM ****************************************************

:pw_input
echo . . . . . . . . . . . . . . . . . . . .
echo . .
echo . Please enter password .
echo . .
echo . . . . . . . . . . . . . . . . . . . .
echo.
echo.

set /p password=

cls

goto connect



REM ****************************************************
REM ** Überprüft Jedes Laufwerk von x-z ob verbunden
REM ** Wenn nicht dann entsprechenden Prozeduraufruf
REM ** Wenn alle verbunden dann Abbruch
REM ****************************************************

:connect

IF NOT EXIST p:\NUL GOTO connect_p
IF NOT EXIST q:\NUL GOTO connect_q


goto all_connected



REM ****************************************************
REM ** Mountet Laufwerk
REM ** Kehrt dann zur Laufwerksüberprüfung zurück
REM **
REM ****************************************************

:connect_p

echo . . . . . . . . . . . . . . . . . . . .
echo . .
echo . .
echo . Mounting Drive p:\ .
echo . .
echo . .
echo . . . . . . . . . . . . . . . . . . . .

C:\Programme\VeraCrypt\VeraCrypt.exe /v f:\Test_TrueCrypt /lp /p "%password%" /q /tc

goto connect



:connect_q

echo . . . . . . . . . . . . . . . . . . . .
echo . .
echo . .
echo . Mounting Drive q:\ .
echo . .
echo . .
echo . . . . . . . . . . . . . . . . . . . .

C:\Programme\VeraCrypt\VeraCrypt.exe /v f:\Test_VeraCrypt /lq /p "%password%" /q

goto connect



REM ****************************************************
REM ** Alle Laufwerke verbunden
REM ****************************************************

:all_connected

echo . . . . . . . . . . . . . . . . . . . .
echo . .
echo . .
echo . All drives mounted .
echo . .
echo . .
echo . . . . . . . . . . . . . . . . . . . .


goto end



:end
Sep 21, 2015 at 5:03 PM
Edited Sep 21, 2015 at 5:04 PM
From the VeraCrypt release notes:

.
Make command line argument parsing more strict and robust (e.g. /lz rejected, must be /l z)
.
You need to put a space between the switch and parameter for your drive letter assignment as shown below.

/l p

/l q

https://veracrypt.codeplex.com/wikipage?title=Command%20Line%20Usage
Sep 21, 2015 at 5:32 PM
Edited Sep 21, 2015 at 6:04 PM
You are right. That was everything. It works now !!!
Thank you so much. You're my hero of the day. :)

The examples on this page are still wrong then (bottom of the page):
https://veracrypt.codeplex.com/wikipage?title=Command%20Line%20Usage

Btw. why it takes so much longer mounting VeryCrypt containers as the old Truecrypt ones?

Edit: Ok found out that typing in the correct Hash Algorithm reduces the time extremly. Still longer as with TrueCrypt containers but it's okay with that. Again thank you and have a nice day.

Problem solved.
Sep 21, 2015 at 6:02 PM
You are welcome. :-)

FYI: You could use VeraCrypt's Favorites built-in functionality to accomplish the mounting of the volumes and setup a hot-key.

https://veracrypt.codeplex.com/wikipage?title=Favorite%20Volumes

https://veracrypt.codeplex.com/wikipage?title=Hot%20Keys

.
Btw. why it takes so much longer mounting VeryCrypt containers as the old Truecrypt ones?
.
VeraCrypt uses higher iterations for the hash algorithm than TrueCrypt to address the issue raised in the TrueCrypt audit reports.

https://veracrypt.codeplex.com/wikipage?title=Header%20Key%20Derivation

https://opencryptoaudit.org/

If you need to lower the wait times to mount your volumes, you can use a lower PIM value when your password is 20 or more characters long.

https://veracrypt.codeplex.com/wikipage?title=Personal%20Iterations%20Multiplier%20%28PIM%29

Also you can set the default hash parameter assuming both VC & TC volumes used the same hash in:

Settings > Default Mount Parameters

When mounting multiple volumes in favorites, the subsequent volumes take longer due to all hash algorithms are tested instead of using the default or selected hash in the first volume.

https://veracrypt.codeplex.com/workitem/199
Sep 21, 2015 at 6:24 PM
Edited Sep 21, 2015 at 6:39 PM
Thank you for the new intel. I will look into this later and think about it but I really love the batch file because only when I click it, the mounting process will start and other PC users won't see anything about True- or Veracrypt.

For now I did it with editing this line to:

C:\Programme\VeraCrypt\VeraCrypt.exe /v f:\Test_VeraCrypt /l q /p "%password%" /q /hash sha-512

Giving it the correct hash algorithm reduces the mounting time of my two test containers from almost 13 seconds to 5 seconds. Im fine with that.

Okay think I am now ready to leave TrueCrypt and say hello to VeraCrypt. :)

Last question I would have is should I stay with my old TrueCrypt containers or creating new ones with VeraCrypt? Have four almost 2TB big ones so it would take very much time.