Context menu for hard drive

IS it possible to customize the right click context menu on the hard drive icons in the folder tree ?

I'd like to ad an item in the menu to unmount an usb external hard drive using driveremove instead of the green arrow in the tray.

Thanks

You can add to the context menu for all drives via the Drive filetype but I'm not sure if there's a way to add to just a single drive.

Ok Thanks, id didn't know there was a hard drive file type... I'll have a look.

You can also make toolbar/menu buttons to eject a specific drive letter using a command like this:

ContextMenu FILE="D:" VERB="Eject"

I don't think the above command will work (in fact i've tried it and it doesn't), cause the hard drive is not recognized as a removable media (which have by default the explorer eject item in its context menu), but as a local hard drive which need the tray icon to be unmout...or the removedrive .exe which does the same using the cmd line.

I will try the drive file association, but as you said it seems that opus (mostly explorer) desn't make a diffrence between fixed hard drive and usb local hard drive even if they are external.

But i'll try and share here the result as it can be usefull for others.

Thanks again for your comittment.

Ok, with the context menu, it works but for all hard drive (which is not the purpose) and it you right click the usb device and launch the eject command, it won't eject for (i think) opus (or explorer) have the handle on the drive.

So the best way to do this is in fact to create a button with the command :

"[your path]\removedrive.exe [your usb drive letter] -l"

the -l option is to loop until the drive is free of any handles.

The removdrive.exe is free and easly find using google.

After this you can disable the "safley remove hardware" icon from your tray which was the purpose of all this stuff.

Hope it will serve to some peoples.

  • forgot to ask :

Is it possible to launch a dos apps mimized ? for removdrive popups a dos window when invoced.


Sorry, i've resolved this alone....

Yup, just set the Run drop-down to Hide in the command editor.

(If it's a multiline command then there won't be a Run drop-down but you can do the same thing by adding a line with runmode hide at the top.)

yop, that's in fact obvious... I resolved it by myself... sometimes eyes are tired after a day in front of a CRT screen...

Oh, i've posted in the coffeeShop section another qquestion related to this one but which would be a little displaced here... If you can have a look :slight_smile:

Thanks

Back to this topic :slight_smile:

I could make the removedrive button working as said before, but i can't do the same int the hade drive file type context menu.
Here is what i do :

  1. for info i have disabled the explorer context menu items in the preferences of Opus.

  2. I had a new action in the context menu of the hard drive.

  3. I set it as a "Run an opus function"

  4. Code is :
    Runmode Hide
    C:\program files\removedrive\RemoveDrive.exe g: -l

Problem : the item doesn't appear in the context menu.

If i choose instead of "run an opus function" Run an application" and put
C:\program files\removedrive\RemoveDrive.exe g: -l
No problem, it appears, but removedrive is not hidden when launched...as i can't ad the runmode hide opus command

What can i do ?

Something like this should work. I don't have the exact command but it works with other command-line tools.

Strangely, the action doesn't appear in the right click menu for drive.
(Of course i've created the action inside the drive file type context menu).
If i shift+right click to override the "hide windows explorer context menu" i've checked in opus option, it doesn't appear either.

In fact, it seems that a menu item appears ONLY when i choose to "run an application (supported by opus and Explorer)"...which prevent me to use the runmode hide command. :frowning:

Oh, heh, I hadn't thought this through properly. :slight_smile:

Drives are shown in My Computer so when you right-click one the context menu is generated by Explorer, not Opus. So you can't use Opus things like "runmode hide" and so on, and have to think of a command which works within Explorer. All Opus is doing in this case is providing an easy way to edit the Drive filetype's context menu.

What might work is creating a normal Windows shortcut file which runs the command with arguments, and Run set to Minimized. Shortcuts don't seem to offer a full Hide option, though.

Maybe a small bit of VBScript glue could also be used to run the command without a DOS window coming up.

Is removedrive.exe a free tool? Where can I get it to test against?

Thanks for answering.

Yep, Remoderive is a free tool. You can find it here

www.uwe-sieber.de

For vbscript, my knowledge doesn't go that far...but it seems to be the only solution.

If you want to use an NT Command Script, you can always add cmdow.exe to your path to hide the Command Prompt window.

Thanks i'll try it.

Ok, the way i do it doesn't seems to work.

If i open a cmd window and enter this :

C:\removedrive\cmdow.exe /run /hid c:\removedrive\RemoveDrive.exe g: -l

i succesfully eject my hard drive.

Problem is, under opus it doesn't work, but anyway i would end with a opening cmd window (the cmdow one) instead of the removedrive.exe one.

Still stuck

You need to use cmdow from within a script and call that script. You and Leo have successfully piqued my interest in this topic now. I have downloaded RemoveDrive.exe and I'm half-way to a working script. Give me some time to work on this, I should have it all working shortly.

[quote="namoi"]Ok, the way i do it doesn't seems to work.

If i open a cmd window and enter this :

C:\removedrive\cmdow.exe /run /hid c:\removedrive\RemoveDrive.exe g: -l

i succesfully eject my hard drive.

Problem is, under opus it doesn't work, but anyway i would end with a opening cmd window (the cmdow one) instead of the removedrive.exe one.

Still stuck[/quote]

I now know why this command worked for you from the Command Prompt, but not when right-clicking a drive in My Computer or a drive button in Opus. In the first case your current directory was not on the drive to be removed, so there were no handles and the drive is removed quickly.

In the other two cases, the current directory (of your File Type command)was changed to the root of the very drive you were trying to remove. RemoveDrive.exe loops while waiting for handles to the drive to be freed. But RemoveDrive.exe was using the root folder of the same drive it was trying to remove as its current directory, which created an endless loop with no way to exit. RemoveDrive.exe would keep checking while it maintained a hold on the drive.

PHPBB_IMPORT_WARNING CODE_NEAR_LI

Okay, I have success, but not as much as I would like, the Command Prompt screen still flashes by, although very briefly.

Here's what the attached .zip archive includes:[ul][li] RemDrive.reg – This file contains the necessary registry keys and values to create a context menu item named Remove Drive attached to the Drives "file type". This menu item appears when you right-click on any drive within the My Computer namespace either from within Windows Explorer or Directory Opus. In Directory Opus, this context menu may also appear when you right-click on your drive buttons (if you do not use the multifunc or multifunctabs parameters).

NOTE: I had to create the required registry value a weird sort of way, so that it would work on anyone's PC, regardless of which drive letter Windows is installed to and regardless of what the Windows folder is named. You cannot manually create this registry value in Windows Explorer - File Types or Directory Opus - File Types--both use string registry values which must always store explicit paths. I used an expandable string registry value, which allows the use of environmental variables within the value; this allows us to store implicit paths that are machine-independent.
[/li]
[li] RemDrive.cmd – This is the actual "executable" run by the registry value created by my RemDrive.reg. This NT Command Script runs RemoveDrive.exe. One downside to attaching the context menu item to the Drive "file type" is that Remove Drive will appear on any drive's context menu. However, we only want to remove removable drives. I wrote this NT Command Script such that it contains logic branching and bounds checking to ensure RemoveDrive.exe is only run on drives identified by Windows 2000/XP/2003 as a "Removable Drive". You can determine this designation yourself using the command below:

fsutil fsinfo drivetype X:
[/li]
[li] Remove.drive.exe – This is the file that actually removes the drive. It is copied to the Utils folder (along with RemoveDrive.txt), so the script will always know where to look for and find it.
[/li]
[li] %SystemRoot%\Utils – This is where all the files get copied to. It is where the registry values expect to find RemDrive.cmd and where RemDrive.cmd expects to find RemoveDrive.exe.

I always create this folder on any system I build. I include it in my system %PATH% environmental variable, as well as make a separate %Utils% variable that points directly to it. I copy any command line or Windows utilities to this folder that should be placed in the system PATH. This would include things like: utilities from SysInternals, utilities having to do with writing NT Command Scripts (like cmdow.exe), or utilities such as those written by Tanis and Nudel for use with Directory Opus commands.

I make this a subfolder of the Windows folder, because the utilities might get used by many different NT Command Scripts on the system, with or without Directory Opus. This subfolder will separate such utilities from Windows system files while keeping them close to the system; it also makes it much easier to audit and keep such utilities up-to-date with the latest versions.
[/li]
[li] Install.cmd - This file installs all of the above files. After installation, everything should work.[/li][/ul]
I did not create an uninstall file, because I would never use it and it might delete files that you might otherwise use.

To uninstall, just manually delete this registry key: HKEY_CLASSES_ROOT\Drive\shell\Remove_Drive, and delete any files from the folder above you no longer want on your system.
RemDrive.zip (44.4 KB)

Great, Thank you very much...

I must say i've found an other way to make it work, but more "blindly".

I just used a batch 2 exe converter with the Silent mode option checked; that way no window appear. But yours is more "pro".

Ok, now if uou want to go further, here is the really hard stuff. All this was made to dispose of the green tray arrow which launch the "safely remove hardware" and that i find annoying.
So first is to find a working way to disable this. I know there's some soft which could do this, but they are memory resident (and not free).
Second, is to find a way to reconnect a removable drive without to have to physically unplug and replug it. This one is tough, cause it seems to me that windows disable the usb port on which the drive is connected when you want to safley remove it. It can be checked in the device manager. Xp says that this hardware has been prepared for safe remove...
But for sure it's possible, it only goes far awat from my competences.

So we'll end with no "safely remove..."icon and a way to disconnect/reconnect an usb hard drive which will be always phisically connected to the computer :slight_smile:

But don't lose your time if you're not interested by this, it's just a little challenge i try to solve and it's getting a little out of topic here.