中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 16:04
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » How to safely delete hardware using batch processing?
Printable Version  3,055 / 9
Floor1 220110 Posted 2005-12-01 16:31
荣誉版主 Posts 313 Credits 718
Recently, too many people are printing resumes. My friend's computer keeps inserting USB drives, MP3s, and keeps clicking "Safely Remove Hardware" from the taskbar...
I want to put the batch file shortcut in the Quick Launch bar and just click it. Can it be done with a batch file? What's the code?
Thanks :>
Floor2 willsort Posted 2005-12-01 16:54
元老会员 Posts 1,512 Credits 4,432
Re 220110:

The batch processing solution hasn't been thought of yet. Just in my memory, when plugging and unplugging USB drives and other devices directly under XP, there is no alarm prompt. It might need some settings, which is unknown. In addition, if you really need to safely remove, you can left - click the hardware icon, and then it only takes two mouse clicks to remove the specified device.
Floor3 JonePeng Posted 2005-12-01 19:50
金牌会员 Posts 1,883 Credits 4,562 From 广东广州
Re 220110 and willsort:

You can use third-party tools Unlocker and unplug to quickly unplug USB drives in batch processing.

The following content is quoted from http://blog.dream4ever.org/venchia/

Method 2
For problems that cannot be solved in a graphical interface like Windows, we need to try to solve them in the dark command line state. First, download the unplug.rar software, extract it, and then run the cmd command to open the command prompt window. Then use the dir command to enter the directory where the unplug.exe file is located. Here, taking stopping the H drive (assuming the H drive is the flash drive location) as an example, enter the command unplug H:. Of course, a more efficient method is to make a batch processing to get it done. (Modify the parameter "d:\unplug" after the cd command in the script to the directory where unplug.exe is located, and "h" to the drive letter occupied by the flash drive), save the following script as usb.bat, and double-click it when needed. If you specify a hot key, you can uninstall it with one click!
The usb.bat is as follows

@echo off
cd d:\unplug
unplug h:

If unplug can't get it done, then it's time for unlocker to come into play

Method 3
Now cooperate with the /s command line of unlocker, first unlock the device drive letter to be uninstalled, then unplug, basically it can be uninstalled at one time.

Attach a script



In this script, if it is still detected that it cannot be uninstalled, if it occurs, run pause to prompt, and if it flashes by, you can pull out the device.

Instructions:
1, Replace with the feature string of your USB drive, use unplug to check
2, Replace the location of unlocker, it is recommended to put both unlocker and unplug in the search path.
3, Since unplug returns errorlevel as 1 regardless of whether unplug is successful or not, so use findstr to judge whether unplug is successful.


Software download used

unplug.rar
Unlocker.v1.66.GR.rar (1.66 green version)
Unlocker.v1.7.3.rar
Floor4 220110 Posted 2005-12-01 22:35
荣誉版主 Posts 313 Credits 718
First of course, thank two friends! Especially little JONG, who also brought up the link address! Thanks!

I once tried to end related processes by using processes, but didn't find related processes. Only after selecting "Safely Remove Hardware" did a "rundll32.exe" appear. It didn't work.
Floor5 220110 Posted 2005-12-01 22:40
荣誉版主 Posts 313 Credits 718
I tried the second plan provided by Xiao JONG, and indeed it flashed by without a prompt. But by checking through hardware management, this hardware is still enabled, so I still dare not remove it casually. After all, it's the client's stuff, and it's not good if it's damaged... Let's all work harder!
Floor6 无奈何 Posted 2005-12-02 23:07
荣誉版主 Posts 356 Credits 1,338
Try MS's own thing, DevCon.

The DevCon command-line utility replaces Device Manager
Summary
The DevCon utility is a command-line utility that replaces Device Manager. With DevCon, you can enable, disable, restart, update, delete, and query a single device or a group of devices. DevCon also provides information related to driver developers that isn't visible in Device Manager.
Link: http://support.microsoft.com/kb/311272/zh-cn
Floor7 220110 Posted 2005-12-03 20:05
荣誉版主 Posts 313 Credits 718
DEVCON, a very powerful command, saw many, many things.

Playing around....
Floor8 htysm Posted 2005-12-07 11:13
高级用户 Posts 415 Credits 866
It's still quite advanced for me, I still need to learn a lot!

Right-click the USB drive, and "Eject" is also okay.
Floor9 220110 Posted 2005-12-07 17:37
荣誉版主 Posts 313 Credits 718
Originally posted by htysm at 2005-12-7 11:13:
Right-click the USB drive and select "Eject" is also okay.


This is also okay, but still troublesome.
If I create a shortcut and assign a function key; then I can just press the key once.
Alas, limited skills, still can't figure out the DEVCON command, please everyone help again. Thanks
Floor10 Michael Posted 2005-12-07 20:01
钻石会员 Posts 3,041 Credits 10,056
In the "Device Manager", expand the "Disk Drives" option, right-click the USB flash drive, open the "Properties" dialog box, select the "Policies" tab, and choose "Optimize for quick removal".
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023