I'm working on a script that will eject a usb flash drive. I did a search on google and the forums and I found a script that people seem to be using for this purpose. However when I try to us it, the script runs but it doesn't eject the usb flash drive
Here is the script exactly as I am trying to test it
#include <Process.au3> $DriveLabel = "BACKUP" ; your drive label here $aDrives = DriveGetDrive("all") ; USB external hard drives report as "Fixed", not "Removable", so use "All" to cover both kinds EjectDrive($aDrives[$i] & "\") $strDrive = $dLetter $oNamespace = $oShell.NameSpace($SSF_DRIVES) $oDrive = $oNamespace.ParseName($strDrive) $oDrive.InvokeVerb ("E&ject") If DriveGetLabel($aDrives[$i]) <> $DriveLabel Or DriveGetLabel($aDrives[$i]) = "Removeable Disk" Then
It's pretty much the exact script found in numerous posts here on the fourm. I only modified the drive label and added some message boxes to see where in the script the problem was.
the script runs fine up until the "if" statement in function EjectDrive(). If I understand the script, that if statement determines if the drive has actually been ejected. If it has then it send the message that it's save to remove the device.
When I run the script is does not actually eject the drive so I'm sure that's why the code in the if statement isn't executed.
The Question: What do I need to do to get the script to actually eject the flash drive.
P.S. I'm using windows 7 32-bit if it makes a difference.