Okay, how about a useful post, this time.
I recently purchased a Windows 8 computer on which I use a number of external USB hard drives, the spinning kind. The problem is that Windows 8 seems to want to make these drives shut off and spin down, presumably to save power.
It has been getting very frustrating and every couple of minutes, I would have to wait an extra 10 seconds for the drive to be available again. In the meantime, programs would be unresponsive and show ‘Program is not responding.’ I just want to keep those drives to stay awake, powered up and spinning.
I tried one utility but it always crashed .NET so that didn’t wasn’t going to do so I started to write one myself but I frankly don’t have the spare time, so I decided to whip one out using a batch file. I found another but it only operated on one drive — I needed to keep two or three drives spinning.
Now understand, I pretty much live in the Windows command prompt, CMD.EXE or rather inaccurately called, the DOS box. So please forgive my instructions being rather terse.
First, one thing I do a little differently is that I have a designated location for programs and utilities on my computer that were not “Installed.” Some people call these “portable apps”. Either way, I didn’t click on a “setup” program to install them. I simply copied them to my hard drive. I call this folder
c:\Program Files mCopy
(Note that I don’t put mCopy in parenthesis in the pattern of Program File (x86). If did originally, but found that it was more error prone to type and also didn’t work with the fancier batch files I tend to create, this one included.)
Some people put these in among their regular “Program Files” but I don’t like that. For one thing, when I get a new computer, I know I can just grab this folder and put it on the new computer without any installation ramification.
You may have other places to put stuff. In the old days, I kept a c:\utility folder for such programs. Either way, designate a location for StayAwake. You will need two files.
The first is StayAwake.bat (right-click and save this link to StayAwake.bat or you may view the full text posted below) which you would put in the folder of your choosing.
You then need to use a text editor (such as Notepad) to create StayAwakeFiles.txt in that same folder. This file should contain one or more lines with fully qualified filenames for StayAwake to create and update on each drive you want to keep spinning.
My StayAwakeFiles.txt contains these two lines:
On each line, I have specified the drive letter, the folder and the name of the file StayAwake is to create. That is what a “fully qualified” filename means.
For me, the two USB drives that I want to keep from powering down are my F: and G: drives. So I picked a folder on each to put a file into. In each case, I’m using the same name, StayAwake.dat.
At this point, you should be able to click on StayAwake.bat from Windows explorer and you’ll get the venerable Command Prompt box showing what the batch file is doing that looks something like this:
You can see that the process started at the same time as each file was written. That means the batch file was not delayed waiting for a drive to spin up.
If a file could be written to, it could be because the drive or folder does not exist. In this case, I edited my StayAwakeFiles.txt to make the folder invalid. Since g:\emp does not exist, it cannot write stayawake.dat and reports the error as:
When you see that, check that the drive letter is correct and that the folder exists. If you think it should still work, double check your spelling. Finally, it could be that you do not have write permissions in that folder.
You will also see this if that drive is not accessible. For example, you might have unplugged or powered down that USB drive.
Setting the delay between cycles.
In the StayAwake.bat file, on the line near the end that starts with “choice /t”. The number that follows is the delay in seconds between write cycles. You can adjust this number to your preference. I set mine at 90 seconds which seems pretty reasonable.
If you find your drives are spinning down, you can reduce that time until the StayAwake cycle is fast enough to keep them spinning.
To cancel the process, click on the Command Prompt StayAwake is running in and press the C key or you can simply “X” the batch file closed.
One limitation of the “for /f” command in a batch file is that your path name cannot contain parenthesis. (There may be other restricted characters, as well.) If you find that your batch file doesn’t run correctly, try moving the files to a folder with a simple name.
Ultimately I probably will likely write a proper Windows program, if for no other reason, to make it more easily configurable for other people to use. In the meantime, if you are up to it, this might be an option for you.
I’m running it just fine with Windows 8 and would expect it to work fine with Windows 7, as well. I’m pretty sure it will work under Windows XP and Vista, as well. I’ve tested it with spaces in the name and they seem to be okay but I cannot guarantee that every symbol on the keyboard will work.
If you are having a problem with StayAwake, please see if you can find a local tech person to assist you. I’m afraid that I cannot diagnose everyone individual situation.
You can try putting the scripts in a simple folder name, such as c:\utility or c:\batchfiles and see if it works there. Likewise, for each file in your StayAwakeFiles.txt, keep those folder and filenames simple, too.
Anyhow, I hope this little utility proves useful to you someone out there! If you get it to work, feel free to use the Contact form in the menu bar to send me a note.
Contents of StayAwake.bat
@echo off rem StayAwake 1.00 from www.SharedEngrams.com and may be freely shared rem so as long as SharedEngrams.com is credited as the source. set stayawakefiles=%1 if %stayawakefiles%/==/ set stayawakefiles=stayawakefiles.txt :loop echo. echo At %time%, StayAwake is using the file list from %stayawakefiles% for /f "delims=" %%f in (%stayawakefiles%) do ( echo -- %time% to "%%f" > "%%f" if exist "%%f" type "%%f" if not exist "%%f" echo Could not write to "%%f" ) ) choice /t 90 /d x /c CX /m "StayAwake: Press C to cancel" if errorlevel 2 goto loop