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-07-07 18:23
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Partially closed]Is there a USB drive letter recognition program like findcd called findusb? View 6,710 Replies 26
Original Poster Posted 2006-04-04 15:57 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Is there a USB drive letter identification program like findusb similar to findcd?

In order to search for USB drive letters in batch processing, is there a USB drive letter identification program like findcd.exe for optical drives, namely findusb.exe?
If there is no ready-made program, is there any expert who can write a batch processing with this function!

[ Last edited by hxj on 2006-4-15 at 04:49 ]
Floor 2 Posted 2006-04-04 17:30 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline

@echo off
echo Drive letter Available space
wmic logicaldisk where Description="Removable disk" get DeviceID,FreeSpace | find /v "DeviceID"
wmic logicaldisk where DriveType="2" get DeviceID,FreeSpace | find /v "DeviceID"
pause>nul

See if it's a similar effect? If you change "可移动磁盘" to "CD-ROM disk", it can return the current optical drive letter.
Other matters are in my signature.
Floor 3 Posted 2006-04-04 22:24 ·  中国 河北 保定 移动
铂金会员
★★★★
网络独行侠
Credits 6,962
Posts 2,753
Joined 2003-04-16 00:00
23-year member
UID 1565
Gender Male
From 河北保定
Status Offline
The person upstairs, by the way, I would like to ask, how to use wmic to execute a command on another machine?
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
Floor 4 Posted 2006-04-04 23:22 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
wmic /node:target IP /user:username /password:yourpassword
Tested in SP2 environment can connect, but it seems that the permissions are insufficient, or the other party has not enabled RPC. Maybe it is because of logging in with an empty password. There is no condition, and I am too lazy to test and find the reason.
Floor 5 Posted 2006-04-05 01:50 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Thanks to 3742668:
The batch script you wrote achieves the goal!
You might as well compile it into an application findusb.exe, which should still be quite useful!
Floor 6 Posted 2006-04-05 04:11 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Then ask 3742668 again:

I omitted "FreeSpace" and only displayed the drive letter "DeviceID" of the USB flash drive, but how can I convert the displayed "DeviceID" into an environment variable that can be used in batch processing?
Floor 7 Posted 2006-04-05 10:00 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
Wrap it with for..

for /f %%i in ('"wmic logicaldisk where DriveType="2" get DeviceID |find /v "DeviceID""') do set mydrv=%%i

Let's see if it works, not tested.
Floor 8 Posted 2006-04-05 10:37 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Originally posted by 3742668 at 2006-4-5 10:00 AM:
Wrap it with for..

for /f %%i in ('"wmic logicaldisk where DriveType="2" get DeviceID |find /v "DeviceID""') do set mydrv=%%i

See if it works ..


Tested, the result drive letter is incorrect, it extracted the file to the current drive (G:) instead of the USB drive (I:) I wanted to extract to.
Previously, I made one up myself that worked, but I always felt it wasn't good, please give me some advice

usb.bat:

@echo off
path %SystemRoot%\system32\wbem;%SystemRoot%\system32\
wmic logicaldisk where Description="Removable Disk" get DeviceID | find /v "DeviceID">a.txt
for /F "tokens=1" %%I in (a.txt) DO set USB=%%I
del a.txt
dosimg KV.img %USB%\ /s>nul
exit

But the above batch file works alone, but when called with call from my main batch file, it has an error, I don't know why

Finally, using start /wait /min usb.bat worked. I'm a DOS noob, these statements are made up randomly, I don't even understand them myself!
Floor 9 Posted 2006-04-05 10:49 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
What about this sentence?


for /f %%i in ('"wmic logicaldisk where Description="Removable Disk" get DeviceID |find /v "DeviceID""') do set mydrv=%%i

Maybe the type of your USB flash drive is not 2. My CD-ROM type is 3 and the USB flash drive type is 2. I'm not at hand now, so I can't test. You can change the DriveType="2" in the previous sentence to 1, 2, 3, 4, 5, etc. for testing.
You can also post the main batch file, and by the way, explain the environment including the directory.
Floor 10 Posted 2006-04-05 11:00 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
: :3Make Jiangmin DOS Anti-virus Flash Drive
REM Make Jiangmin DOS Anti-virus Flash Drive
path %Programfiles%\winrar
start /wait /min winrar e -p88888888 KV.pak kv.iso dosimg.exe -o+
start /wait /min winrar e kv.iso ezboot\kv.img -o+
cls
echo.
echo.
echo.
echo.
echo Now laoding databank into U disk, please wait......
start /wait /min usb.bat
del/q a.txt
del/q kv.i*
del/q d*.exe
GOTO BACKTOMENU

Windows XP system, current directory g:\dosav\kv\

Your version is relatively concise, I will continue to try!
Floor 11 Posted 2006-04-05 11:19 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
Okay! Using your first batch file, adding %SystemRoot%\system32\;%SystemRoot%\system32\wbem to the PATH was successful!

Thank you very much, expert, for your guidance, it has been very beneficial!
Floor 12 Posted 2006-04-15 04:47 ·  中国 上海 东方有线
中级用户
★★
Credits 377
Posts 66
Joined 2005-04-04 00:00
21-year member
UID 37817
Gender Male
Status Offline
This problem was originally solved, but now there is a problem of identifying the USB flash drive drive letter under DOS 7.1. It seems that the method of 3742668 can only be done under Windows. Is there any way under pure DOS?

[ Last edited by hxj on 2006-4-15 at 04:48 ]
Floor 13 Posted 2006-07-21 21:33 ·  中国 江苏 苏州 电信
初级用户
★★
Credits 160
Posts 75
Joined 2006-06-28 01:07
20-year member
UID 57661
Gender Male
Status Offline
wmic logicaldisk where Description="Removable Disk" get DeviceID,FreeSpace | find /v "DeviceID"

Is this wmic an internal command?
Why have I never heard of it before?
And on my machine, using wmic /? doesn't find relevant help information either
Floor 14 Posted 2006-07-21 21:56 ·  中国 山西 太原 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re buddiyar:

wmic is obviously not an internal command, but it is a default installation component of WinXP/03. When you run wmic for the first time, it will prompt you to install to complete the configuration, and you can directly use it in cmd or batch files later. Please refer to:

WMI Command Line
http://www.cn-dos.net/forum/viewthread.php?tid=19738#pid115977
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 15 Posted 2006-09-11 21:06 ·  中国 河北 唐山 联通
版主
★★★
操作系统爱好者
Credits 1,113
Posts 392
Joined 2002-11-11 00:00
23-year member
UID 228
Gender Male
Status Offline
The character judgment of "removable disk" does not take into account the situation of USB-HDD (local hard disk).
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
tireless +1 2008-11-16 20:09
DOS之家 http://doshome.com 站长 葛明阳
Forum Jump: