3

Is there any way to eject external hard drive safely which is currently connected to the pc only using cmd? I can only use cmd right now and GUI is out the question.

1
  • 1
    I know you can use C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL hotplug.dll to bring up wizard to eject USB device. See if you can Google about Control_RunDLL hotplug.dll and see if there's an api method or some parameter you can pass such as UUID, deviceID, or hardware name or something like that to always eject the needed device. If you can do it with C# or C code, you can run that in PowerShell which you can in turn run using native cmd only and windows CMD native with nothing further needed, period. Commented Apr 30, 2020 at 15:48

1 Answer 1

1

You can use command below and consider changing the ParseName parameter with your drive letter

Single line using the Run dialog or CMD:

powershell (New-Object -comObject Shell.Application).Namespace(17).ParseName(\"E:\").InvokeVerb(\"Eject\")

Using PowerShell

powershell (New-Object -comObject Shell.Application).Namespace(17).ParseName("E:").InvokeVerb("Eject")

it seems that, below option in some cases only remove the drive latter.

Use the diskpart utility to safely remove a disk drive. This is useful when you have no GUI, for example in Server Core or Hyper-V Server.

  1. On command prompt, type diskpart and wait for the new prompt, then type list volume. Take note of the number of your desired volume by watching its drive letter (be carefull!!!)
  2. Type select volume <number>, where is the number of your USB storage.
  3. Then, type remove all dismount. Type exit to leave diskpart. Enjoy! ;)
  4. Now you can safely remove your USB storage device from the Hyper-V server.

According to the diskpart remove's help (type "help remove" inside diskpart):

2
  • I have tried doing this but the hard drive’s led is still flashing.. usually it stops flashing after ejecting.. Commented Apr 30, 2020 at 14:09
  • @ManavSinghChauhan , you are right, kindly check the updated answer, i hope this could help you Commented May 6, 2020 at 4:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .