As a part of a tool I list the drives that are available on several workstations, including a number of properties. Since in my particular case it's accessing remote workstations over the network, I'm using WMI (a ManagementObjectCollection), but my question would as well arise if I were using the 'IsReady' property of a DriveInfo object.
In order to avoid runtime errors, I'm checking the 'IsReady' status of each drive before retrieving it's properties. Some of the SATA HDDs, however, seem to enter some kind of 'sleep' status after a while of inactivity – thus return 'FALSE' to the function, despite being available and accessible. As a result, the drive's properties are not listed.
How can I triger something like a'wake up call' in my code? My only idea would be to catch the error, wait for some seconds and try 'IsReady' again... it just seems really clumsy to me. Any advice is highly appreciated!
What I have tried:
After manually 'waking up' the relevant drives (e.g. by opening an Explorer window) 'IsReady' returns TRUE and – after a re-start of the tool – the code can retrieve the drive's properties.