Drive Keep Alive

Drive Keep Alive LogoI wrote this program to deal with my WD My Passport USB hard drive spinning itself down due to inactivity.  This program will keep any drive up and running whether it is an internal drive or an external drive.  If you have a WD My Book, WD My Passport, or any brand of external hard drive that shuts itself down after a period of inactivity then this program is what you have been looking for.  The WD drives are especially annoying because the inactivity spin down feature is coded into the firmware, with no utility to change the settings.  What this means is that even if you tell Windows not to shut off the hard drive, it will still turn itself off.  This program keeps the drive running by writing the line “alive” to a alive.txt text file on your drive every 10 seconds.  When the program first starts up it will ask you what the drive letter is to your drive.  Open Computer or My Computer and find your drive.  It should have a letter such as “J:”.  Enter this letter into the program without the : and hit enter.  As long as this program is running your drive should stay running.  I would advise against using this program if you have your USB drive plugged into a laptop running on the battery, and your USB drive powers itself through the USB cable (the drive doesn’t have a separate power cable) as running the drive constantly will drain your laptop battery faster.

Planned features:

  • The ability to supply the drive letter as a command line argument.
  • A Windows Service version of the program that you can set up to run in the background automatically when your computer starts.
  • Have the program delete the alive.txt file on program close.
Download Drive Keep Alive Download the source code

Here is the source code:

// Name: Drive Keep Alive
// Author: Warren Held
// Date: Feb 14 2012
// Version: 1.0
// License: Creative Commons Attribution-NonCommercial-ShareAlike CC BY-NC-SA

#include "stdafx.h"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
// Prompt user for the drive letter and build the path
string DriveLetter;
cout << "Enter the drive letter for the drive you want to keep alive and hit enter." << endl;
cout << "(Just the letter, no :'s or \\'s please)" << endl;
getline(cin, DriveLetter);
string Path;
Path = DriveLetter + ":\\alive.txt";
cout << "I will keep the drive located at " << DriveLetter << ": up and running." << endl;

while (true)
// Write the word alive to alive.txt
ofstream AliveFile; ( Path );
AliveFile << "alive" << endl;

//10 seconds between file writes
return 0;