China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 07:06
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed]Is there a batch script to delete a USB drive View 13,422 Replies 66
Floor 31 Posted 2007-06-28 15:07 ·  中国 广东 汕头 电信
新手上路
Credits 2
Posts 1
Joined 2007-06-28 11:27
18-year member
UID 92569
Gender Male
Status Offline
Floor 32 Posted 2007-07-02 13:51 ·  中国 江苏 常州 电信
新手上路
Credits 10
Posts 5
Joined 2006-06-13 02:49
20-year member
UID 56936
Status Offline
Floor 33 Posted 2007-07-02 15:06 ·  中国 广东 广州 珠江宽频
初级用户
★★
Credits 170
Posts 72
Joined 2007-03-11 22:16
19-year member
UID 81435
Gender Male
Status Offline
Hey, can you modify it to achieve real-time monitoring of USB storage devices and automatically delete them once detected?
Floor 34 Posted 2007-07-02 15:07 ·  中国 广东 广州 珠江宽频
初级用户
★★
Credits 170
Posts 72
Joined 2007-03-11 22:16
19-year member
UID 81435
Gender Male
Status Offline
Add a delay, but it feels that it will cause the system performance to decline
Floor 35 Posted 2007-08-21 13:39 ·  中国 山东 烟台 莱阳市 联通
初级用户
Credits 43
Posts 22
Joined 2007-08-21 12:44
18-year member
UID 95494
Gender Male
Status Offline
Extremely powerful! Thanks to the LZ for sharing!!!
Floor 36 Posted 2007-09-07 17:42 ·  中国 江苏 南京 建邺区 电信
初级用户
Credits 41
Posts 24
Joined 2007-09-04 20:16
18-year member
UID 96564
Gender Male
Status Offline
Thanks for sharing
Floor 37 Posted 2007-09-14 18:31 ·  中国 江苏 南京 电信
新手上路
Credits 2
Posts 1
Joined 2007-09-14 17:53
18-year member
UID 97387
Gender Male
Status Offline
I used "Win+R" to bring up the console.
After entering the command: for /f %i in ('devcon findall usb* ^|find /i "usb mass storage"') do devcon remove "@%i", the console window closed directly.
When I replaced the command with: for /f %i in ('devcon findall usb* ^|find /i "usb mass storage"') do echo hello, the console still closed automatically.
I directly ran devcon findall usb*, which worked normally.
Running devcon findall usb* | find /i "usb mass storage" worked normally.
I don't know where the problem lies.
Floor 38 Posted 2007-10-27 23:08 ·  中国 四川 达州 电信
初级用户
Credits 20
Posts 10
Joined 2007-04-23 02:35
19-year member
UID 86141
Gender Male
Status Offline
Let's give it a try. I don't know if it will work well.
Floor 39 Posted 2007-10-29 01:00 ·  中国 浙江 温州 电信
初级用户
Credits 31
Posts 16
Joined 2007-10-24 00:08
18-year member
UID 100602
Gender Male
Status Offline
Learning! There are many things I don't know, and now I'm dizzy.
Floor 40 Posted 2007-12-22 16:16 ·  中国 黑龙江 哈尔滨 联通
初级用户
Credits 109
Posts 40
Joined 2007-12-22 15:41
18-year member
UID 106471
Gender Male
Status Offline
Floor 41 Posted 2008-01-14 12:41 ·  中国 河南 新乡 电信
新手上路
Credits 8
Posts 3
Joined 2007-12-01 14:05
18-year member
UID 104351
Gender Male
Status Offline
I used it, but it was recognized immediately after deletion. After removing the devcon rescan test, I found that my USB mouse was also uninstalled, and I had to use devcon rescan to load it again.按理说 the line find /i "usb mass storage" is already limited to only uninstalling USB storage devices... Why doesn't mine work? Running the command devcon findall usb* alone and running the command devcon findall usb* |find /i "usb mass storage" gives the same result
Floor 42 Posted 2008-02-27 10:33 ·  中国 山东 青岛 联通
新手上路
Credits 6
Posts 5
Joined 2008-01-05 10:54
18-year member
UID 107720
Gender Male
Status Offline
A very good tool wants to be downloaded. Please give some points, hehe
Floor 43 Posted 2008-03-29 23:44 ·  中国 陕西 西安 联通
新手上路
Credits 16
Posts 8
Joined 2008-03-29 21:13
18-year member
UID 114388
Gender Male
Status Offline
Hehe ~ very classic~ My suggestion is to add a delay in the middle, so that there is enough time to unplug the USB~ For example, ping 127.1 -n 20 >nul
Just my humble opinion~
Floor 44 Posted 2008-03-29 23:47 ·  中国 陕西 西安 联通
新手上路
Credits 16
Posts 8
Joined 2008-03-29 21:13
18-year member
UID 114388
Gender Male
Status Offline
@echo off
for /f %%i in ('devcon findall usb* ^|find /i "usb mass storage"') do devcon remove "@%%i"
ping 127.1 -n 20 >nul
devcon rescan
pause

echo Hehe, test successful, very good, very powerful~
Floor 45 Posted 2008-03-30 12:13 ·  中国 河北 沧州 任丘市 中国石油工程设计有限公司
新手上路
Credits 2
Posts 1
Joined 2007-10-20 11:03
18-year member
UID 100237
Gender Male
Status Offline
Classic! I like it
Forum Jump: