Win7 Command Line USB Safely Remove?

I am looking for a command line command to safely remove a USB hard drive in Windows 7.

The old standby of "rundll32 shell32.dll Control_RunDLL hotplug.dll" will not work in Windows 7 because it brings up the old dialog which cannot remove things that aren't Windows 7 ejected.  Windows 7 expects an eject of a Windows 7 USB flash drive.

I'm not looking for a 3rd party program to do this.  I'm just looking for a command line command I can give that will do the Windows 7 eject.

coder1313514512456Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

stranger9002Commented:
I'm afraid this won't be a much help, but that's not problem of command, but UAC. You can try to run it as administrator, and there is also command runas:
runas.exe /user:PC\Administrator appYouWantToRun.exe (I guess it will work for  "rundll32 shell32.dll Control_RunDLL hotplug.dll" also)

But it would ask for the password.
or you can use  /savecred and it will store the password - but of course it's not very recommended

And the last possibility and also not secure is to disable UAC
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
baldwinr99Commented:
You can use USB Safely remove tool.  It has full function command line ability via "usr.exe" along with GUI interface if you ever need it.  It is attached and I believe it is free for personal use.
usbsafelyremovesetup-4-2-5.exe
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

brandongohwhCommented:
Simple command line for universal usage: " Rundll32 Shell32.dll,Control_RunDLL HotPlug.dll "
0
brandongohwhCommented:
Actually, you do not need to eject if you are veru sure that Windows 7 is not meddling with your flash drive (unless it is formatted under NTFS). But other than that, you can go to device manager > disk drives > <name> > policies > check quick removal.
You can always try to go to Drivers and Printers and see if you can eject from there
0
coder1313514512456Author Commented:
Thanks everyone for the responses.  I haven't abandoned this, it's just that these solutions aren't completely working for me.  They are great ideas and I do appreciate them.
stranger:  can't seem to get runas to accept what I'm typing, it just keeps giving me the runas help screen.
Again, I'm just looking for a command line command I can give that's not a 3rd party piece of software.  That being said, I really like the 3rd party solutions people have provided, so thank you!
 
0
coder1313514512456Author Commented:
Well, after some investigating, it looks like this is about as far as I've gotten for the time being.  Thanks everyone for your responses!
 
0
coder1313514512456Author Commented:
Looks like this is a little more complicated than I thought.  Thanks everyone for your time on this!

0
PorpathamCommented:
Hi,

Microsoft provides a utility called devcon for free download. It's a "Command Line Uility Alternative to Device Manager". It can actually do many things that I won't get into here, but removing a plug & play device is a simple operation once you know the unique name of the device you want to manipulate.

After you've downloaded devcon, run "devcon status *" in a command window. This will generate a list of all the devices on your system. Look for the line which describes your device. In my case for my external hard drive the (very cryptic) line looks like this:

For Example we take:  Maxtor external hard drive it will show as
SBP2\MAXTOR&ONETOUCH&LUN0\0010B9F700AFC279

That full line is a bit much but any substring that remains unique will do. I have another maxtor drive on my system but nothing else that has the phrase "sbp2\maxtor" so I'll use that. The command to safely remove my external drive then becomes:

devcon remove sbp2\maxtor*
The "*" at the end is a wildcard and matches the rest of the string.

Be certain to select the right device. In my case, installing the Maxtor drive actually installed three devices all labeled with "maxtor onetouch" - its firewire interface, its front panel interface, and finally the drive itself. It's the latter that I want to remove. Looking at the details of the "Safely Remove Hardware" dialog will help you select the appropriate entry.

Finally, be careful. Devcon can certainly cause problems if you delete the wrong device by mistake. A reboot or a re-run of the "add new hardware" wizard may restore you, but that's a risk I'd rather avoid.

Please Reply
0
eeds49Commented:
Try this tool, it works for me:

http://safelyremove.com
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.