Link to home
Start Free TrialLog in
Avatar of DanBAtkinson
DanBAtkinson

asked on

Adding a 'Safely remove hardware' option to the context (right click) menu in My Computer

Hi there,

I was wondering whether anyone had written a shell extension or other program that added a feature that does the following:

Add a 'Safely remove this device' option when you right click on a removable drive in My Computer. The extension I want would automatically know which device I want to remove when I right click it and not just bring up the 'Safely Remove Hardware' option that can be achieved at the bottom right hand corner of the taskbar.

I really would like to have this option as I am always in Explorer copying files from drive to drive and putting them onto non-networked computers. It would save me a lot of time if I could just go up to My Computer, right click and select 'Safely remove this device' as I generally have 4-6 devices attached at any one time (CD Drives, Printers, modems, USB drives etc).

I'm offering 500 points for this one because I want it THAT much!

If anyone can come up with a quick program (or knows where I can get detailed information on how to create such an extension to the context menu), then I'd appreciate it greatly.
Avatar of hitman4hire
hitman4hire

Add a programs to the right click menu

Here's an example adding notepad to the right click menu.

Run REGEDIT.
Navigate to HKEY_CLASSES_ROOT*. (This should be the very first subtree.)
A key called "shellex" should already be here. Add a new key called "Shell" at the same tree level as "shellex."
Under the "Shell" key, create another key called "Notepad."
Create another key under the "Notepad" key called "Command."
You'll see a string value named Default when you highlight the "Command" key. Double-click Default and enter "NOTEPAD %1" (without the quotes). Click OK.
Exit Regedit and test it out.
Note:The full path to the correct Registry key is: HKEY_CLASSES_ROOT*ShellNotepadCommand

ADD WORDPAD TO RIGHT-CLICK MENU FOR EVERY FILE

Run REGEDIT.
Navigate to HKEY_CLASSES_ROOT*. (This should be the very first subtree.)
A key called "shellex" should already be here. Add a new key called "Shell" at the same tree level as "shellex."
Under the "Shell" key, create another key called "Wordpad."
Create another key under the "Wordpad" key called "Command."
You'll see a string value named Default when you highlight the "Command" key. Double-click Default and enter "C:Program FilesAccessoriesWORDPAD.EXE %1" (without the quotes or the appropiate path to wordpad.exe). Click OK.
Exit Regedit and test it out.
Note: The full path to the correct Registry key is: HKEY_CLASSES_ROOT*ShellWordpadCommand

Hope this is what you were looking for. You can go right here for full infomation.

http://searchwinsystems.techtarget.com/tip/1,289483,sid68_gci1039684,00.html




Adding A ShortCut To Desktop In The Right Click Menu
http://www.spreadfirefox.com/?q=node/view/975



Here is what you want:

This will bring up the GUI:
rundll32.exe shell32.dll,Control_RunDLL hotplug.dll

To automate the job of safely removing a device completely, you can use
deveject.exe available here (includes C++ source code as well):

ftp://ftp.heise.de/pub/ct/listings/0316-208.zip

For help, run deveject.exe /? in a command prompt.

Works for Windows 2000/XP/2003.

If you can intergrate that into the right click menu with the link posted above:
Adding A ShortCut To Desktop In The Right Click Menu
http://www.spreadfirefox.com/?q=node/view/975

It should do what your asking :)

Source:
http://www.codecomments.com/VBScript/message407965.html
Avatar of DanBAtkinson

ASKER

Thankyou. I do know how to add shortcuts to the right click menu.

But...

My problem is rather customised. I'm not trying to add a generic program like Notepad to it (which I've already done anyway).

I'm trying to add a 'Safely Remove Device' button which at the very least will require a bit more than a simple registry editing since I require something that is able to remove the specific device that I right clicked on.

Thanks all the same though.
Did you see my post? You can download that file , create a batch file /shortcut to do what your asking then place that shortcut on the right click menu.
DoTheDEW335 :

Thanks. That would almost do it. But I would still need to specify the removable device in the command line arguments once it's added to the context menu.

For example if I run this, all I could do is run deveject. I would still need to write in the device drive letter (which can be variable), the PID, which again to my knowledge is variable, and the name of the device (which once again is variable).

Although the source is enclosed, I don't write in C++.

So if anyone is able to give any hints or tips on how to customise it to my problem, I would be very happy.

Thanks again.
DoTheDEW335:

No I didn't see your post (or the one after) as I was writing mine whilst you were posting yours!!! If you know how to / can create a batch file to do what would be needed, then I'd be grateful.

Thanks.
Specify device in command line, hope this helps too.

http://support.microsoft.com/kb/87165/EN-US/
No I'm afraid as MSCDEX.EXE relies on command line switches and not batch files. Plus MSCDEX is not included with Win XP.
Forgot about that! dos & Xp.
Any other ideas?
ASKER CERTIFIED SOLUTION
Avatar of DoTheDEW335
DoTheDEW335

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get the following error:

Invalid drive specification 'E'!
Usage: c:\deveject -EjectDrive:<Drive>|-EjectName:<Name>|-EjectId:<DeviceId> [-v] [-Debug]
DevEject 1.0  2003 c't/Matthias Withopf

Invalid drive specification 'F'!
Usage: c:\deveject -EjectDrive:<Drive>|-EjectName:<Name>|-EjectId:<DeviceId> [-v] [-Debug]
DevEject 1.0  2003 c't/Matthias Withopf

Invalid drive specification 'G'!
Usage: c:\deveject -EjectDrive:<Drive>|-EjectName:<Name>|-EjectId:<DeviceId> [-v] [-Debug]
DevEject 1.0  2003 c't/Matthias Withopf

Despite that I have removable drives in F and G.
I have added the : after the drive letter and it appears to work (although the actual DriveEject is vetoed).

;(E:)
@echo off
deveject -EjectDrive:E:

;(F:)
@echo off
deveject -EjectDrive:F:

;(G:)
@echo off
deveject -EjectDrive:G:
Points are awarded to DoTheDEW335 as it's not his fault that my stupid computer vetoes deveject DeviceEjects!

Thanks for your help!
Sorry bout that, I didn't quite test it like I meant to before putting out that information for you.. I am glad you got it. Thank you for the accept!