Menu

On command line mounting, veracrypt executable immediately returns without waiting for operation finish

poisonborz
2021-01-11
2022-08-05
  • poisonborz

    poisonborz - 2021-01-11

    Hey! On Windows command line, when using mounting (but probably any) command for veracrypt.exe, the executable immediately returns/exits. This makes shell scripting - like doing operations after the mount is available - hard. It is unknown when the operation is actually finished (eg. the container is mounted). There are some options like /beep or /explorer, but these are UI-centric and not usable for scripting.

    Ideally, the executable should wait until the operation is finished, and only then return with an exit code.

     

    Last edit: poisonborz 2021-01-11
  • Gary Marks

    Gary Marks - 2021-01-12

    In this case, the immediately subsequent continuation of batch file processing after your mount command isn't a shortcoming caused by VeraCrypt, but by Windows. I use VB Script instead, and script processing can easily be forced to wait for the return value of the VeraCrypt mounting operation, just like you want. But rather than convincing you to use VB Script, I'll give you a slightly less elegant way to delay your batch file until the mounting is complete.

    [your mounting command to use drive letter H:]
    :VerifyMount
    IF NOT EXIST H:\ TIMEOUT /T 1 /NOBREAK >NUL & GOTO VerifyMount
    [batch file continues...]

    If there's a problem mounting and this results in an endless loop, CTRL-BREAK will end it.

     
    👍
    1
  • J-D

    J-D - 2022-08-05

    In this case, the immediately subsequent continuation of batch file processing after your mount command isn't a shortcoming caused by VeraCrypt, but by Windows.

    Really? Some programs have no problem running until they are done.

     
    • Gary Marks

      Gary Marks - 2022-08-05

      You're right, J-D. I'm much more used to using VB script where execution is asynchronous unless the "bWaitOnReturn" parameter of the Run method is explicitly set to True. But that's no excuse for giving bad or incomplete information concerning batch processing as I did. Sorry! Batch files often execute programs synchronously as you say, although some programs have special requirements and operate asynchronously no matter what, perhaps by launching a separate background task and exiting the foreground task. I don't know if this issue with VeraCrypt has been quietly addressed or if changes in my own system are affecting my results, but I can't even replicate the OP's problem on my computer anymore. I've seen similar reports of the same issue, and I could swear I've witnessed it myself, but when I test it now, VeraCrypt's mounting command executed in a batch file always seems to wait until completion before returning control to Windows batch processing. Any immediately subsequent batch commands on the mounted drive letter succeed without special polling procedures like I posted in my earlier response. In case this is a coding change, I'm now using v1.25.9.

      But not to skip over the highlights, I was wrong and you are right, J-D :)

       

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.