Click here to Skip to main content
15,918,268 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everybody,

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!

Kind regards
Mick

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.
Posted
Updated 15-Jan-20 2:59am
Comments
Richard MacCutchan 15-Jan-20 8:20am    
The Power settings tool in Control Panel allows you to switch off (i.e. sleep) the hard drive after a period of inactivity. Users may set this value to anything they wish.

1 solution

The problem is not trying to wake up the drive. You have to wake up Windows.

Try checking out the technique in Wake the PC from standby or hibernation[^].
 
Share this answer
 
Comments
Sonhospa 15-Jan-20 9:20am    
Thank you, Dave. However, it must be something drive-specific as on the same machine e.g. 4 drives are reported TRUE (IsReady) while 2 others aren't - at least not before waking them up manually.
Dave Kreskowiak 15-Jan-20 10:20am    
and how do you "wake them up manually"?
Sonhospa 15-Jan-20 10:43am    
For example by opening an Explorer window (Network list -> server name -> drive letter)
Dave Kreskowiak 15-Jan-20 15:41pm    
So you've got drives that go to sleep even when a user is working around in Windows? That's weird.
Sonhospa 17-Jan-20 12:45pm    
Hi Dave, sorry for the delayed response. It may seem weird but is still true - only for some SATA drives. If a user accesses the particular HDD, it takes a few seconds to 'wake up' from some kind of standby-mode I suspect. As mentioned, after waking up I get 'IsReady = TRUE'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900