PDA

View Full Version : External Drive Reminder?


bluemicrobyte
12-23-2007, 10:50 PM
So I have this external hard drive -- there aren't any bright lights on it or things to remind me that it's turned on and needs to go off so sometimes I end up leaving it running for days on end wasting electricity and wearing out the disk.

I'm wondering if there's a way to program windows XP to "remind" me to turn it off when I try to turn off my computer (or any other event like going idle). A simple popup or tonal sound or something to remind me that I need to turn off the hard drive would be great. Obviously I'd only want this reminder to go off if the hard drive were "connected" to the computer at the time.

Is this possible? (obviously I don't think it's built in to XP, but I'm wondering if there's another way)

Modred
12-24-2007, 12:42 AM
What sort of external HD is it? My WD MyBook has a built-in feature that puts the drive in standby after a certain period of inactivity and automatically shuts off when power from the computer shuts off. The creator of the drive may have created some sort of tools like that for your drive, but I can't be certain.

bluemicrobyte
12-24-2007, 2:30 AM
One is an Acomdata firewire drive, the other is a generic (actually its "CoolMax") enclosure that runs on USB. I somehow doubt the manufacturers offer such a feature. Both drives run on external power (AC plug for each).

I don't know if there's some way to write a program that can give me a popup if the drive is connected when I hit shutdown........

TimP
12-24-2007, 4:35 AM
You can't chain it on shutdown per se. I believe Windows prevents individual applications from stalling or aborting a shutdown process.

You can use WMI (Windows Management Instrumentation) and adapt a script to alert you, though. MSDN has some sample scripts here (http://msdn2.microsoft.com/en-us/library/aa394592(VS.85).aspx) and the script that does what you need (kind of) is "How do I distinguish between a fixed hard disk and a removable hard disk?". The sample script enumerates through all disk drives and identifies their type. I'm slightly busy with the holidays at the moment, but I can try to hack something together in the next few days unless you want to tackle it yourself. The logic goes something like this:

Enumerate though all drives
- If any removable devices were found, pop up a message box
- Otherwise run shutdown.exe

You could put a "Shutdown Computer" shortcut on your desktop to initiate shutdowns. There may even be registry hacks to get the Shutdown button to actually call your script.

Another option (slightly more complicated) would be to write a Windows service that monitors hard disks. It would be possible to add something like "if the device has been plugged in for more than two hours, alert the user".

EDIT:
Here's a basic proof-of-concept script I just modified.

strComputer = "."
shutDown = True
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")


For Each objDisk in colDisks
If objDisk.DriveType = 2 And (objDisk.MediaType = 11 Or objDisk.MediaType = 12) Then
shutDown = False
Wscript.Echo objDisk.DeviceID & " is a removable device."
End If
Next
If shutDown = True Then
Wscript.Echo "Shutting down"
Else
Wscript.Echo "Not shutting down"
End If


It should print "Shutting down" to a command prompt window when there are no removable devices attached and "Not shutting down" if there are. Copy and paste the code to a file named "checkdisk.vbs" and run it through a command prompt with "cscript checkdisk.vbs".