We've talked before about how some external drives spin down after a fairly short time by design, and that unfortunately some of them won't allow this behavior to be altered at all. The WD MyBooks are notoriously bad for this, spinning down after 10 minutes of no physical disk access. It's the physical-access requirement that makes it unacceptable. In particular, there may be enough data cached in something that you're streaming (like music) so that the drive doesn't get hit for a read for longer than the timeout period. This will subsequently cause an ugly break in the stream when the disk does get accessed, and has to spin back up. This is bad for the hardware, and infuriating for the user (e.g., me).
I've searched in vain for an official or otherwise elegant solution for this. So I spent some time on this last night and today. After trying simple read commands like VOL and DIR, and getting nowhere (they end up cached after the first iteration), and doing some reading on flushing HDD cache, it struck me that there is no way to do this without writing to the disk. I wanted to stay away from that on general principles, but I have not come up with something that works reliably, or with so little data having to be processed. All it takes is copying a very small file to the drive with verify, and then deleting it. The non-obvious part was getting the batch file to wait as long as possible between writes. I definitely don't want to do this constantly. That search went well. I found out that ping works with minimum overhead for this, while an alternate method using the CHOICE batch command pegs the CPU usage.
KeepOalive.bat:
@echo off
ECHO Keep the O: drive from spinning down
:REP
copy c:\autoexec.bat o:\temp/V > NUL
del o:\temp\autoexec.bat
rem ECHO.
rem ECHO Waiting 360 seconds
rem ECHO.
@ping 127.0.0.1 -n 2 -w 1000 > NUL
@ping 127.0.0.1 -n 360 -w 1000> NUL
goto REP
The file can be anything, anywhere. I chose c:\autoexec.bat for now because it's there and it's only 278 bytes. (C: is my WinMe drive, though I haven't booted into Me for years. Heh.) The NULs prevent text writes to the console, saving a few cycles. The /V forces a verify of the write. The ping is bogus and will have to exit via its timeout parameter, making it a timed-pause command. The extra ping with a timeout of 2 seconds is probably not necessary. The site I got this wait method from said it made the pause time more accurate, but a few seconds inaccuracy here is irrelevant. I left it in for now.
This has zero impact on performance, according to task manager. And it works. Yay! I've tested it, managing to keep the offending drive spinning continuously for the better part of an hour. It sits on the taskbar (after you minimize it) as a reminder to close it when you no longer want to force this behavior.
Anything more elegant and even less intrusive would be most welcome.