Install Windows 7 Dari Flashdisk Command Prompt
Cara membuat flashdisk bootable dangan Command Prompt: 1. Pada perangkat komputer lain yang berjalan di windows XP/Vista/7, klik Run kemudian ketik CMD (dengan menekan tombol bendera Windows + R).
I'm constructing a backup script for Windows 7, and the last action I want it to perform is to safely 'remove' the USB drive that it is backing up to. I am under the impression that plugging the drive into the same USB port all the time will keep the same DEV_ID (correct me if I'm wrong). With a command line (or PowerShell), how can I tell Windows to safely remove the hardware automatically without user input?
Just as a place holder, other OSes that may have a way to do this would be great to know as well.
Peter Mortensen5 Answers
stijnstijnBesides Uwe Sieber's RemoveDrive mentioned in the other answer, there are a whole bunch of utilities that can accomplish this. A small list follows:
USB Disk Ejector is primarily a GUI-based utility but can be used equally well from the command-line to eject the drive that the program is running from, or any drive by specifying the drive letter / (partial) drive name / mountpoint etc. Free and open source.
USB Safely Remove is not free but it's a disk removal utility on steroids, with lots of advanced features, including of course command-line support. Zentimo is its bigger brother, with evenmorefeatures.
Microsoft's own DevCon is the command-line version of Device Manager. Besides the original Win2K/XP-era version available from the KB page, there are newer releases (both 32 and 64-bit) available from various MS sources as mentioned in this Where to find DevCon.exe article. DevCon.exe for Windows 7 (and probably Windows 8 as well) can be found buried in the appropriate Windows Driver Kit (WDK), as mentioned in this thread (which also contains download links to the extracted executable).
devcon status *
ordevcon hwids *
ordevcon findall =usb
(for a more compact listing) should tell you the hardware ID of the device. For example:USBVID_0781&PID_71130001162825
Name: USB Mass Storage Device
Driver is running.You can then try removing the device with
devcon remove 'USBVID_0781&PID_7113'
(wildcards like * are allowed, but be careful or you might end up removing something else entirely!)
Someone asked 'Is there a DOS prompt (cmd.exe from Win7) command to eject a thumb drive?' which was unfortunately closed as a duplicate of this thread. However, the question was about ejecting USB drives while in the Windows Recovery Console / System Recovery Command Prompt, so it is unlikely any of the utilities above will help. In such a situation, the following method using Diskpart should work:
Type
diskpart
and wait for the diskpart prompt (DISKPART>
)Type
list volume
Note the volume number of the USB drive carefully (use listed properties such as drive letter, label, type and size for help)
Type
select volume <number>
, where<number>
is the volume number noted aboveType
remove all dismount
Type
exit
to quit Diskpart
Now you should be able to safely remove your USB drive without fear of data loss.
To answer to this question.. You don't need third party stuff.
Reinstall Windows From Command Prompt
With a Command Line (or PowerShell), how can I tell Windows to safely remove the hardware automatically without user input?
Run this command: RunDll32.exe shell32.dll,Control_RunDLL hotplug.dll
to bring up the Safely Remove Hardware dialog box:
Since it's a backup device, it means it's a storage device, therefore it can be done from powershell - just replace X: with your desired drive letter:
OvermindOvermindAccording to this 7tutorials-article, you can enable safe unplugging by setting 'Quick removal'. This will disable write caching per device, of which the performance impact is 'negligible'?Their steps for Windows 7 are below.
(Edit) According to this howtogeek-article, you should still be careful when setting 'Quick removal'. This will disable write caching, and will thus prevent most problems. But some program(s) may still be writing stuff 'live', until explicitly ejected/removed. (End of edit) Manvasanai serial episode 100.
Command Prompt From Windows Setup
Steps:
- plug in the device in the USB drive
- open Device Manager
- expand Disk Drives
- right-click your removable drive, e.g. 'USB2.0 Flash Disk USB Device.'
- select Properties
- click the Policies tab
- enable 'Quick removal' (disable 'Better performance')
(Edit) Note that you need to use Device Manager to change the setting, it can not be done from the File Explorer. (At least in my Windows 10 edition.)