Closed nohopestage closed 2 years ago
Not sure really, does it work if you try -D
switch instead of -d
at the command line? Do you get other error messages if you try that? Could you try with Process Explorer and see if there are any processes holding open handles to the volume when this happens? (Search both for ImDisk and the drive letter.) Chances are that something like an antivirus application or similar is holding something open for a longer time then expected.
It did work with -D
, which I overlooked, and I didn't get any error messages with that. I've tried -R
, but that didn't really remove the VD. It was still visible in both explorer (though I couldn't access it anymore) and imdisk -l
. I couldn't find any processes holding open handles to the volume. Should I always use -D
? Thanks for the reply
Are you sure that you are running the command with administrative privilegies? If you are running as a regular user, it fails to safely dismount the file system and this causes exactly this behaviour.
Btw, -R
is only meant for "emergency" scenarios and should not normally be used if there are other ways available.
I did try running it with as both regular user and administrator. Both resulted in the same output:
Flushing file buffers...
Locking volume...
E: Access is denied.
Btw, as I've just found out there is a .NET library, I tried unmounting the VD that way, which gave me the same error. Is there a way to use -D
in RemoveDevice()
? If not, could such an option be added as an optional bool parameter?
I don't remember right now, I have not used it for many years. I can check later and come back!
It appears that you could set ImDiskAPI.APIFlags = UnsafeNativeMethods.ImDiskAPIFlags.ForceDismount
before you call RemoveDevice
.
That way it does remove the device from explorer. However, the device is still listed in -l
, and when I try to detach it again, it says:
Error opening device: The device has been removed.
That prevents ImDisk from uninstalling.
Device disappears from both explorer and -l
when I detach it with -D
.
Yes, that is expected. If the volume is in use by something and cannot be safely dismounted, when you force it to dismount it needs to stay present until the last reference to it goes away. The ImDisk driver will repeatedly check and see if it is still in use and if not, it will eventually delete the device object and after that the driver can be uninstalled.
When I access the mounted volume and then try to unmount it, sometimes it says access denied and I'm unable to do so, even though I'm not using the volume anymore. The only option in such a case is to restart my computer. What could be the problem?