title: Spin Down Hard Disk Programmatically on Windows?
body: <p>How do you request Windows to spin down a hard disk programmatically? Is there any user-mode function I can call (or kernel-mode function to call or IRP to send) in order to make this happen?</p>
  
  <p>I've tried making a program to send an <a href="http://msdn.microsoft.com/en-us/library/ff551322.aspx">ATA STANDBY command</a> directly to the hard disk, but the problem is that this method doesn't inform the system, and hence whenever the system needs to flush the cache, it'll wake up the hard disk again. How do I tell the <em>system</em> to do this for me? (If the system does it, it'll save up the cache and "burst" the data when it gets too large, instead of writing in small increments.)</p>
  
  <p>(The entire point here is to do this <em>directly</em>, <strong>not</strong> by changing the system-wide spin-down timeout to a 1-second period and waiting for the disk to spin down. I need a function I can call at a specific moment in time when I'm using my laptop, not something generic that doesn't suit 95% of situations.)</p>
  
  <hr>
  
  <p>How far I've gotten so far:</p>
  
  <p>I have a feeling that <a href="http://msdn.microsoft.com/en-us/library/ff559654.aspx">PoCallDriver</a> and <a href="http://msdn.microsoft.com/en-us/library/ff550784%28VS.85%29.aspx">IRP_MJ_POWER</a> might be useful for this, but I have very limited kernel-mode programming experience (and pretty much zero driver experience) so I really have no idea.</p>
  
  <hr>
  
  <h2><strong>Please read:</strong></h2>
  
  <p><em>Update</em>:</p>
  
  <p>People seem to be repeatedly mentioning the solutions that I have already mentioned do not work. Like I said above, I've <strong>already tried</strong> "hacky" solutions that change the timeout value or that directly issue the drive a command, and the <em>entire reason</em> I've asked this question here is that those did <strong>not</strong> do what I needed. <em>Please</em> read the <em>entire</em> question (especially paragraphs 2 and 3) before repeating what I've already said inside your answers -- that's the <em>entire difficulty</em> in the question.</p>
  
  <hr>
  
  <p>More info:</p>
  
  <p>I've found <a href="http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/Disk_Idle_Detection.doc">this document about Disk Idle Detection</a> to be useful, but my answer isn't in there. It states that the <em>Power Manager</em> sends an IRP to the disk driver (hence why I suspect <code>IRP_MJ_POWER</code> to be useful), but I have no idea how to use the information.</p>