05-08-2023, 09:15 PM
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.
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.