Looking for a reliable way to determine if a drive letter is in use
#11
Thanks to all who responded. I'll go through all the suggestions to see what works, but I did figure out a kind of kludge way of making it work for now.

I found that I could use "SHELL" to run a command like

dir D:\ > DriveStatus.txt 2>&1

This will direct the standard output as well as any error to a text file called DriveStatus.txt

If the drive letter is really and truly not in use this will return a message that says "The system cannot find the path specified".

In either of the other two cases that I noted in my original post, it will return a different message for each of those situations. As a result, I can parse that DriveStatus.txt file to determine exactly what the state of that drive is.

It's just a little ugly, but it seems to be working.
Reply


Messages In This Thread
RE: Looking for a reliable way to determine if a drive letter is in use - by hanness - 05-08-2023, 09:15 PM



Users browsing this thread: 17 Guest(s)