Menu

Scripting non-system volume mounting

2021-10-24
2021-10-25
  • Michael Moratz-Coppins

    Hi, I've used TrueCrypt for automating my backup procedures on Windows for many years, and it seemed like VeraCrypt's command line switches were near-identical but I'm having trouble. When I run this command:

    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v \Device\Harddisk4\Partition0 /a /k C:\users\mike\desktop\keyfile /mountoption rm

    I get a VeraCrypt dial-up box which I have to click OK for it (nothing else) to mount the partition. Is there something I'm missing in the command in order to get VeraCrypt to just mount the encrypted partition without any further interaction?

    I've played with /q and or /s as well, /q seemingly does nothing to change the above outcome and /q and /s results in literally nothing at all happening (VeraCrypt doesn't even start, or it starts and closes so quickly that I didn't even see it in Task Manager).

     
  • Adrian Kentleton

    Do you really have a 'Partition0' on your PC; there are none on mine!

    If you specify /q, /a is implicit, so redundant. If you specify /s, you will not see any Veracrypt generated error messages.

     

    Last edit: Adrian Kentleton 2021-10-24
  • Michael Moratz-Coppins

    If you take a clean drive and set up a Veracrypt volume on it, it's partition 0. When it's not mounted, it looks like an unused disk to the OS.

     
  • Adrian Kentleton

    Couid you post a screenshot of that, please. And of the Veracrypt 'dial-up box', whatever that is, when it appears?

     
  • Michael Moratz-Coppins


    I've no idea how to post a screenshot here, here's an attempt!

     
  • Michael Moratz-Coppins

    'dial-up box' - lol, just realised I typed that instead of 'dialog box' :D And yes it's harddisk3 now not 4, and I updated my command accordingly before running it.

     

    Last edit: Michael Moratz-Coppins 2021-10-24
  • Adrian Kentleton

    a. Your screenshots are showing up in the email I get, but not on the forum thread. Did you use the 'Add attachments' dialog? (I've screenshot yours as they appear in my email.)

    b. What happens if you simply use /v \Device\Harddisk3?

     
  • Michael Moratz-Coppins

    the 'enter password' dialog box

     
  • Michael Moratz-Coppins

    the 'select partition' box

     
  • Adrian Kentleton

    Here's your screenshots, as they appear in the email notification I get, tho' they don't appear to me in the forum thread. Did you use the 'Add attachments' dialog?

    What happens if you just specify /v \Device\Harddisk3?

     
  • Michael Moratz-Coppins

    '\Device\Harddisk3': I get 'the handle is invalid'.

    I used the image button on the forum toolbar the first time around, then did forum attachments after you asked.

     

    Last edit: Michael Moratz-Coppins 2021-10-24
  • Adrian Kentleton

    And if you use /v \Device\Harddisk3\Partition1?

     
  • Michael Moratz-Coppins

    'cannot find the file specified'

     
  • Adrian Kentleton

    Have you tried mounting it via its ID? Mount it, select it in the GUI, find its ID via 'Properties', and copy and paste that into /v ID:alongstringofhexadecimalnumbers!

     
  • Michael Moratz-Coppins

    same problem as with ...\Partition0.

     
  • Enigma2Illusion

    Enigma2Illusion - 2021-10-24
    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v \Device\Harddisk4\Partition0 /a /k C:\users\mike\desktop\keyfile /mountoption rm
    

    I think the two problems are:

    1. FYI: Windows can change the order of discovering your devices during boot/reboot. Especially if you add/remove devices.
    2. You are using auto-mount /a in your command. Auto-mount is "Mount all device-hosted VeraCrypt volumes" which attempts to mount all discovered disk partitions attached to your PC.

    Try:

    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v \Device\Harddisk3\Partition0 /mountoption rm /k C:\users\mike\desktop\keyfile 
    
     
  • Enigma2Illusion

    Enigma2Illusion - 2021-10-24

    FYI: By not creating a Windows partition of the entire HDD (partition1) since it appears you want to use the entire drive, Windows will be prompting you to format Harddisk3 once it is encrypted since it appears unavailable for use.

    Too many users have lost their encrypted data or made recovery difficult because they accidently clicked on Format button instead of the Cancel button.

    To avoid this problem, use Windows Create and Format Disk to create one partition for the entire size of the HDD since it appears you want to use the entire hard drive space.

    Always have frequent backups of your data due to hardware failure, software issues or user error which can cause loss of access to both encrypted volumes and unencrypted drives.

     

    Last edit: Enigma2Illusion 2021-10-25
  • Michael Moratz-Coppins

    I tried:

    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v \Device\Harddisk3\Partition0 /mountoption rm /k C:\users\mike\desktop\keyfile
    

    and

    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v ID:B675C30CFA6F4B041F92515EB89F7C99D80FF7BEF57C43F53F353AE194B00590 /k C:\users\mike\desktop\keyfile /mountoption rm
    

    And I just get presented with the main VeraCrypt window as if I had just started VeraCrypt myself from the application shortcut.

    Either of these commands:

    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v ID:B675C30CFA6F4B041F92515EB89F7C99D80FF7BEF57C43F53F353AE194B00590 /a /k C:\users\mike\desktop\keyfile /mountoption rm
    
    "C:\Program Files\VeraCrypt\VeraCrypt.exe" /v \Device\Harddisk3\Partition0 /a /k C:\users\mike\desktop\keyfile /mountoption rm
    

    Get me to the 'enter password' dialog box (with the keyfile option already ticked and ready to go) that when I click OK, it successfully mounts the partition. What I'm trying to do is automate the mounting of the partition so I don't have to click on OK.

    Btw, I've never been presented with the "do you want to format this volume" prompt, because as far as Windows is concerned, the disk hasn't even been initialised yet (Windows Disk Management asks me if I want to use GPT/MBR for that disk).

     

    Last edit: Michael Moratz-Coppins 2021-10-25
  • Enigma2Illusion

    Enigma2Illusion - 2021-10-25

    Are you using a password for the volume?

    If yes, you are going to get prompted with the password dialog box because you did not hardcode the password switch /p option in your command.

    If no password, then you need the /tryemptypass switch.

    https://www.veracrypt.fr/en/Command%20Line%20Usage.html

    Btw, I've never been presented with the "do you want to format this volume" prompt, because as far as Windows is concerned, the disk hasn't even been initialised yet (Windows Disk Management asks me if I want to use GPT/MBR for that disk).

    Another scenario that VeraCrypt users have encountered is when performing OS major upgrades, sometimes Windows tries to be helpful by initializing disks that appear uninitialized to make them ready for use in Windows.

    An example of a major upgrade would be Windows 10 21H1 to 21H2.

     
    👍
    1
  • Michael Moratz-Coppins

    /tryemptypass did the trick, thank you!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.