I've added an event-driven task so that any mounted VeraCrypt volumes are dismounted when the PC is hibernated. This runs successfully in dismounting the drive according to the VeraCrypt GUI but the drive letter is not being freed according to Windows i.e. the mounted drive still appears in File Explorer but reports as unavailable if accessed.
This issue doesn't happen if the dismount is performed through the GUI.
Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the exact same issue when triggering the command line from a scheduled task (to dismount volumes after system is idle for 60 minutes). The previously used drive letters get stuck but seem to eventually go away after some time. I assume it's a windows maintenance task figuring things out and making them available again or something, but until then no amount of doing anything else I've found from command line (fdisk etc) or GUI things (diskmgmt.msc etc) sees them other than explorer.exe or can help, nor does killing explorer.exe completely and reloading it (and yes even waiting 10 minuts first) seems to do the trick to get rid of them.
The scheduled task that dismounts any mounted volumes after 60 minutes of computer idle...
The last 2 mounted volumes were X:\ and then Y:\, they dismounted because you can click them and get this, but you can't re-use those drive letters until they eventually clear hours later...
Definitely a bug with scripted command line, works fine if I do it manually (not in a scheduled task). I already tried "run with highest privileges" no change.
Last edit: David L Goodloe 2023-01-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In this case I assume a racing issue. The dismount may be incomplete when Windows enters hibernation. Is it possible to delay hibernation until the drive letter becomes available again via your task? Or at least try to add a few second (or a few more) delay after dismount command, for testing purposes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Root cause: SHChangeNotify(SHCNE_DRIVEREMOVED) is asynchronous by default. In CLI mode with /q, the process exits before Explorer processes the notification — the drive letter stays in the shell namespace cache.
Fix: Add SHCNF_FLUSH flag in Silent mode to force synchronous notification. See the PR for full analysis.
This also applies to GitHub issues #337 and #1426.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've added an event-driven task so that any mounted VeraCrypt volumes are dismounted when the PC is hibernated. This runs successfully in dismounting the drive according to the VeraCrypt GUI but the drive letter is not being freed according to Windows i.e. the mounted drive still appears in File Explorer but reports as unavailable if accessed.
This issue doesn't happen if the dismount is performed through the GUI.
Any ideas?
I have the exact same issue when triggering the command line from a scheduled task (to dismount volumes after system is idle for 60 minutes). The previously used drive letters get stuck but seem to eventually go away after some time. I assume it's a windows maintenance task figuring things out and making them available again or something, but until then no amount of doing anything else I've found from command line (fdisk etc) or GUI things (diskmgmt.msc etc) sees them other than explorer.exe or can help, nor does killing explorer.exe completely and reloading it (and yes even waiting 10 minuts first) seems to do the trick to get rid of them.
The scheduled task that dismounts any mounted volumes after 60 minutes of computer idle...

The last 2 mounted volumes were X:\ and then Y:\, they dismounted because you can click them and get this, but you can't re-use those drive letters until they eventually clear hours later...


Definitely a bug with scripted command line, works fine if I do it manually (not in a scheduled task). I already tried "run with highest privileges" no change.
Last edit: David L Goodloe 2023-01-23
Does this happen if you dismount your volume without hibernating? Please post your terminal command for the dismount.
Greets
"C:\Program Files\VeraCrypt\VeraCrypt.exe" /dismount /silent /quit
Only happens when hibernating.
In this case I assume a racing issue. The dismount may be incomplete when Windows enters hibernation. Is it possible to delay hibernation until the drive letter becomes available again via your task? Or at least try to add a few second (or a few more) delay after dismount command, for testing purposes.
I've found the root cause of this bug and submitted a fix as a pull request on GitHub: https://github.com/veracrypt/VeraCrypt/pull/1658
Root cause: SHChangeNotify(SHCNE_DRIVEREMOVED) is asynchronous by default. In CLI mode with /q, the process exits before Explorer processes the notification — the drive letter stays in the shell namespace cache.
Fix: Add SHCNF_FLUSH flag in Silent mode to force synchronous notification. See the PR for full analysis.
This also applies to GitHub issues #337 and #1426.