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 05:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed]Is there a batch script to delete a USB drive View 13,416 Replies 66
Original Poster Posted 2006-12-14 08:52 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 906
Posts 346
Joined 2006-07-10 09:58
19-year member
UID 58334
Gender Male
Status Offline
Plays the role of popping up the window in the picture

[ Last edited by HAT on 2008-10-22 at 11:44 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
linquanhouzi +1 2008-03-30 12:10
Floor 2 Posted 2006-12-14 10:45 ·  中国 北京 联通
中级用户
★★
带走
Credits 435
Posts 88
Joined 2005-09-24 19:22
20-year member
UID 42793
Status Offline
I'll send you an attachment for you to study by yourself.
Attachments
ReScanUsb.rar (14.85 KiB, Credits to download 1 pts, Downloads: 738)
Floor 3 Posted 2006-12-14 13:16 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Just found it while researching ^_^
Floor 4 Posted 2006-12-14 13:32 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by lxmxn at 2006-12-14 00:30:

  Tried it, it seems that it can only split text files. Splitting other files may damage the file structure, making the file unusable.

You replied to the wrong post upstairs? Hehe^_^
Floor 5 Posted 2006-12-14 13:42 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Hmm. I replied to the wrong one. I'll delete it immediately.
Floor 6 Posted 2006-12-14 20:59 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
It seems to be immediately recognized by the system again ^_^
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 7 Posted 2006-12-14 21:08 ·  中国 河北 廊坊 三河市 移动
初级用户
Credits 55
Posts 16
Joined 2006-10-27 21:01
19-year member
UID 68519
Gender Male
Status Offline
Floor 8 Posted 2006-12-14 21:29 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Correct usage:
for /f %%i in ('devcon findall usb* ^|find /i "usb mass storage"') do devcon remove "@%%i"
After removing the USB flash drive, unplug it, then execute devcon rescan
Or you don't need to execute devcon rescan, the next time you insert it, it will automatically rescan the USB flash drive
Floor 9 Posted 2006-12-14 21:36 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
It's immediate recognition!
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 10 Posted 2006-12-14 22:38 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by ccwan at 2006-12-14 08:36:
It's immediate recognition!!!

I tried several times last night. The correct method:
Execute "for /f %%i in ('devcon findall usb* ^|find /i "usb mass storage"') do devcon remove "@%%i" to remove the USB flash drive, then unplug the USB flash drive, and then execute "devcon rescan" to scan new hardware. If executed together, the USB flash drive is not unplugged in time and is scanned out; of course, you can also not execute "devcon rescan"
Floor 11 Posted 2006-12-15 07:13 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 906
Posts 346
Joined 2006-07-10 09:58
19-year member
UID 58334
Gender Male
Status Offline
for /f %%i in ('devcon findall usb* ^|find /i "usb mass storage"') do devcon remove "@%%i"

ZH159. I executed the command you said. The result is as shown in the following picture:
http://photo.bababian.com/20061214/CCDD60BD673FC5FF4525D5B71E7CD1F9.jpg
Floor 12 Posted 2006-12-15 07:24 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
In the command line, when executing the for statement, %%i should be changed to %i, which is different from %%i in batch scripts.
Floor 13 Posted 2006-12-15 10:10 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 906
Posts 346
Joined 2006-07-10 09:58
19-year member
UID 58334
Gender Male
Status Offline
Which senior can just write a command for me. I'll modify this. Can't remove that. Just can't.
Floor 14 Posted 2006-12-15 10:17 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 906
Posts 346
Joined 2006-07-10 09:58
19-year member
UID 58334
Gender Male
Status Offline
ZH159 big shot

"You just need to remove that line where devcon rescan is added in your bat. Because this is for rescanning. ReScanUsb~ You just need to delete that line and there's no need for rescan. Also, you can just reply directly instead of sending me a private message."

Do you mean to remove the letters devcon rescan? Keep the rest unchanged. I tried but it still doesn't work. Is there any problem with spaces? Can you send it again? Please help, kind person
Floor 15 Posted 2006-12-15 10:37 ·  中国 北京 联通
中级用户
★★
带走
Credits 435
Posts 88
Joined 2005-09-24 19:22
20-year member
UID 42793
Status Offline
......
It should be no problem. You just want to delete the device, so in that P processing file, as long as there is this line:

for /f %%i in ('devcon findall usb* ^|find /i "usb mass storage"') do devcon remove "@%%i"

devcon rescan is to rescan the device, so you don't need to add it.

I think I explained it very detailedly~
1 2 3 5 Next ›
Forum Jump: