USB Safely Remove Buttons

Hi,

here are some buttons to control USB Safely Remove (http://safelyremove.com).

Stop current Drive

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Stop Drive</label>
	<icon1>#delete2</icon1>
	<function type="batch">
		<instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; STOP -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction>
		<instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction>
	</function>
</button>

Stop current Drive forced

<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none">
	<label>Stop Drive (forced)</label>
	<icon1>#delete2</icon1>
	<function type="batch">
		<instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; forcedstop -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction>
		<instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction>
	</function>
</button>

Return stopped Drive

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Return stopped Drive</label>
	<icon1>#undo2</icon1>
	<function type="batch">
		<instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; return -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction>
		<instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction>
	</function>
</button>

Show who prevents a Drive from stopping

<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none">
	<label>Who locks Drive?</label>
	<icon1>#rename2</icon1>
	<function type="batch">
		<instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; wholocks -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction>
		<instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction>
	</function>
</button>

Open USB Safely Remove Main Window

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Open Main Window</label>
	<icon1>C:\Program Files (x86)\USB Safely Remove\USBSafelyRemove.exe,0</icon1>
	<function type="normal">
		<instruction>C:\Program Files (x86)\USB Safely Remove\USBSafelyRemove.exe</instruction>
	</function>
</button>

Suggestions welcome...

Yours,

Marc

Addition for easier use:

The same buttons as before as one menu-structure:

<?xml version="1.0"?> <button backcol="none" display="both" separate="yes" textcol="none" type="menu"> <label>USB Safely Remove</label> <icon1>C:\Program Files (x86)\USB Safely Remove\USBSafelyRemove.exe,0</icon1> <button backcol="none" display="both" textcol="none"> <label>Stop Drive</label> <icon1>#delete2</icon1> <function type="batch"> <instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; STOP -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction> <instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction> </function> </button> <button backcol="none" display="both" separate="yes" textcol="none"> <label>Stop Drive (forced)</label> <icon1>#delete2</icon1> <function type="batch"> <instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; forcedstop -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction> <instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction> </function> </button> <button backcol="none" display="both" textcol="none"> <label>Return stopped Drive</label> <icon1>#undo2</icon1> <function type="batch"> <instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; return -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction> <instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction> </function> </button> <button backcol="none" display="both" separate="yes" textcol="none"> <label>Who locks Drive?</label> <icon1>#rename2</icon1> <function type="batch"> <instruction>&quot;C:\Program Files (x86)\USB Safely Remove\usr.exe&quot; wholocks -d {sourcepath} &gt; %TEMP%\USRResult.txt</instruction> <instruction>SHOW PLUGIN=text %TEMP%\USRResult.txt</instruction> </function> </button> <button backcol="none" display="both" textcol="none"> <label>Open Main Window</label> <icon1>C:\Program Files (x86)\USB Safely Remove\USBSafelyRemove.exe,0</icon1> <function type="normal"> <instruction>C:\Program Files (x86)\USB Safely Remove\USBSafelyRemove.exe</instruction> </function> </button> </button>

Seems to me a little bit funny to pay money for such a program (Safely Remove).

This one has less features but it's free and portable too.
quick.mixnmojo.com/usb-disk-ejector

[quote]
Seems to me a little bit funny to pay money for such a program (Safely Remove). [/quote]

Quite understandable if you're looking only for the safe remove-function.

But USR has several further uses which makes it a "must" for me:

[ul]
Preventing specific drive-letters from being used by USB-Devices
Automatic execution of functions or programs when mounting or unmounting (for example Truecrypt-Mount etc)
User-defined labelling of the devices (great when you use more than one external drive)
Hiding of unoccupied slots of a cardreader
Mounting drives into a filesystem-folder
and much more
[/ul]

I suggest having a look at it if you're not absolutely sure you don't need any of this.

BTW: They've got a very affordable flat-licence for companys :wink:

Saw, it is a lifetime-license and one can use the prog on more than one PC.
For that, the price is ok. I was a little too fast :slight_smile: .

[quote="MarcWinter"]

Show who prevents a Drive from stopping

[code]

<?xml version="1.0"?> Who locks Drive? #rename2 "C:\Program Files (x86)\USB Safely Remove\usr.exe" wholocks -d {sourcepath} > %TEMP%\USRResult.txt SHOW PLUGIN=text %TEMP%\USRResult.txt [/code][/quote]

Hi Marc,

Thanks very much for these buttons. I'm having a problem with the one above. It always gives the following output, no matter what the device or what files are actually locking it:

There are 3 processes are locking device "SanDisk SanDisk Cruzer USB Device (M:,K:)"

Process     Process file name
-------     --------
dopus.exe   C:\Program Files\GPSoftware\Directory Opus\dopus.exe
cmd.exe     C:\Windows\system32\cmd.exe
usr.exe     C:\Program Files (x86)\USB Safely Remove\usr.exe

Am I doing something wrong?

Thanks,
Tom

I should have added that my system is Vista x64 SP2, running Directory Opus 64-bit.

I'm noticing a few other oddities with USB Safely Remove, such as an inability to keep the drive letter fixed on my Palm Pre despite explicitly setting the drive letter in the USR's device properties dialog.

I will take this issue over to the USB Safely Remove forums.

Tom

If you run the buttons when Opus is showing the device, the command will be run with the device as its "current directory", which locks the device. (The same will happen if you open a command prompt and CD to the device, which is effectively what these buttons do.)

You should navigate away from the device before running the button. (Or it might be possible to make the button navigate away for you.)

[quote="leo"]If you run the buttons when Opus is showing the device, the command will be run with the device as its "current directory", which locks the device. . . .
You should navigate away from the device before running the button. [/quote]

Okay, that makes sense. But I guess it kind of defeats the purpose of the button's original XML. Unless the device is selected in the Lister, the {sourcepath} control code won't pass the device's mount letter to USB Safely Remove.

Yes, that's the ticket. The button should put {sourcepath} into a variable, navigate AWAY from {sourcepath}, and then pass the variable to USB Safely Remove. Thanks for the good idea!

Tom