Using this software to SetRemovableMediaBitCommand to USB device

Jun 28, 2014 at 11:30 PM
Hey There,

I read the following post on another site:
My library here has a class that describes the command which can be used to flip the RMB.
Note that it only works if the flash drive supports it.

The post references this code base.
I've grabbed the source ... compiled it ... and fumbled my way to the following ...

private static void TestRMB()
    {
        using (var file = new Win32FileStream(@"\\.\CdRom0", FileAccess.ReadWrite, FileShare.ReadWrite, FileMode.Open, FileOptions.None))
        using (var spti = new Win32Spti(file.SafeFileHandle, true, true))
        using (var cd = new ScsiDevice(spti, true))
        {
            cd.SetRemovableMediaBit(new SetRemovableMediaBitCommand(false));
        }
    }
I would appreciate any help I could get.
First I don't know how to change \.\CdRom0 to reference my usb drive.
Second I don't know if more code is required then what I've cobbled together.

Thanks much,
-- Brian
Coordinator
Jun 28, 2014 at 11:35 PM
Hi there,

It's been a long time since I did this, so I'm not sure if I remember correctly, but I think all you need to do is replace \.\CdRom0 with \.\PhysicalDriveX where X is the appropriate drive number (which you'll have to find some other way). The rest should work as you already have them.

Hope this helps.
Jun 28, 2014 at 11:54 PM
Thanks very much,

I tried out the code but ...
When I try to execute it I get the following exception from ScsiDevice.ExecuteCommand:
IllegalRequest
InvalidCommandOperationCode

Which I assume means that my device doesn't support the WindowsAPI.

Was worth a try :)

Thanks again,
-- Brian
Coordinator
Jun 28, 2014 at 11:56 PM
Ah, yes, that means your device doesn't support it. It has nothing to do with Windows though, it's a flash drive feature. Not every flash drives supports the command, so you're out of luck unfortunately.
Jul 31, 2014 at 11:34 AM
Edited Jul 31, 2014 at 11:35 AM
Hi Ciuppa, I'm really interested in modifying Removable Bit on USB keys. Can I ask you if you can post the executable you created to set/clear the removable bit?
Would it be possible to pass the drive number through the command line?
I have to change the RMB on several thousands of USB keys, I tried the BootIt 1.07 utility but it doesn't work with Alcor controller chips. I can change it with the AlcorMP utility, but with this method I have to erase and rewrite every usb key.
A command-line utility would be extremely useful!
Thank you :-)
Coordinator
Jul 31, 2014 at 11:43 AM
Hi niente0, I believe the RMB command in my library is exactly the same one used by the BootIt utility, so if that one doesn't work, then this one won't either.
Jul 31, 2014 at 12:32 PM
Hi,

That code never worked for me.
I mean it worked.
It was not successful because the usb drive didn't support that command.

-- Brian


Jul 31, 2014 at 2:57 PM
Thanks both! :-)
My only hope is to find a specific utility that configures the Alcor controller, like this one for Phison usb drives: http://flashboot.ru/files/file/418/

Cheers