![]() |
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-26 13:42 |
47,813 topics / 349,918 posts / today 0 new / 48,275 members |
| DOS批处理 & 脚本技术(批处理室) » How does batch processing detect USB drives? |
| Printable Version 3,860 / 23 |
| Floor1 nvflash | Posted 2006-09-26 22:46 |
| 初级用户 Posts 38 Credits 126 | |
|
Searched for a long time, no result, here I hold the last hope, hope everyone can help me, thank you very much!
The general idea of this program is like this: If there is a USB mobile device (format it and return "Format successful") Otherwise ( Return to execute again ) |
|
| Floor2 redtek | Posted 2006-09-26 22:59 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
| Floor3 pengfei | Posted 2006-09-26 23:55 |
| 银牌会员 Posts 485 Credits 1,218 From 湖南.娄底 | |
|
Please be careful!!!
@echo off setlocal enabledelayedexpansion for /f "skip=1 tokens=1,2 delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do ( set genre=%%i set genre=!genre:~-2! for %%1 in (!genre!) do ( fsutil fsinfo drivetype %%1 | findstr "移动" >nul 2>nul && if /i not "%%1"=="A:" echo Found removable storage device, may be USB drive=%%1 ) ) pause |
|
| Floor4 namejm | Posted 2006-09-27 01:13 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
The code in 'Building 3' has conditional restrictions: it needs to be run with administrator privileges under Windows XP and later systems. However, when I tested it on my computer, the types of external hard drives and USB flash drives still showed as fixed drives, which is a bit strange.
|
|
| Floor5 nvflash | Posted 2006-09-27 02:07 |
| 初级用户 Posts 38 Credits 126 | |
Originally posted by pengfei at 2006-9-26 23:55: Could you please explain the meaning of this code segment? Also, regarding the code for judging whether the formatting was successful, why doesn't it work? format "USBHDD" /q /s /y if errorlevel==0 (echo Formatting succeeded ) else ( echo Formatting failed ) As expected, it should display "Formatting failed" if it didn't format normally, but every time it displays "Formatting succeeded". [ Last edited by nvflash on 2006-9-27 at 02:14 ] |
|
| Floor6 vkill | Posted 2006-09-27 08:18 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
Originally posted by namejm at 2006-9-27 01:13: Me too |
|
| Floor7 pengfei | Posted 2006-09-27 09:14 |
| 银牌会员 Posts 485 Credits 1,218 From 湖南.娄底 | |
|
Really depressed...
It works when I test it on my computer! Attachments 1.jpg (37.51 KiB) |
|
| Floor8 namejm | Posted 2006-09-27 09:30 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Maybe some settings were changed, and then the keyword "move" can't be found. Please find the reason.
|
|
| Floor9 vkill | Posted 2006-09-27 09:32 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
Originally posted by pengfei at 2006-9-27 09:14: What's your icon arrangement like? |
|
| Floor10 nvflash | Posted 2006-09-27 09:37 |
| 初级用户 Posts 38 Credits 126 | |
Originally posted by pengfei at 2006-9-27 09:14: Then, if I want to format this USB flash drive now, what variable should I use to represent the drive letter? |
|
| Floor11 pengfei | Posted 2006-09-27 09:42 |
| 银牌会员 Posts 485 Credits 1,218 From 湖南.娄底 | |
|
I'm not sure if the variable was used improperly. I made a change:
@echo off setlocal enabledelayedexpansion for /f "skip=1 tokens=1,2 delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do ( set genre=%%i set genre=!genre:~-2! for %%a in (!genre!) do ( fsutil fsinfo drivetype %%a | findstr "移动" >nul 2>nul && if /i not "%%a"=="A:" echo Found removable storage device, possibly USB flash drive=%%a ) ) pause The drive letter variable for formatting the USB flash drive is %%a [ Last edited by pengfei on 2006-9-27 at 10:39 ] |
|
| Floor12 vkill | Posted 2006-09-27 09:45 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
All are displaying drives
Attachments aa.BMP (52.87 KiB) |
|
| Floor13 pengfei | Posted 2006-09-27 09:48 |
| 银牌会员 Posts 485 Credits 1,218 From 湖南.娄底 | |
|
The brother upstairs shows that the command fsutil fsinfo drives is correct. Could it be that the pipe command after 'fsutil fsinfo drives^|find /v' didn't execute successfully.
|
|
| Floor14 nvflash | Posted 2006-09-27 09:58 |
| 初级用户 Posts 38 Credits 126 | |
Originally posted by pengfei at 2006-9-27 09:42: I express extremely high respect for the brother's help! |
|
| Floor15 nvflash | Posted 2006-09-27 10:33 |
| 初级用户 Posts 38 Credits 126 | |
|
But on my computer, it still can't be detected, nothing is displayed, so it pauses
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |