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 17:13
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Partially closed]Is there a USB drive letter recognition program like findcd called findusb? View 6,708 Replies 26
Floor 16 Posted 2006-09-11 21:12 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Tip: Home edition of XP has no wmic~~~

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 17 Posted 2006-10-09 04:13 ·  中国 广东 汕头 电信
新手上路
Credits 2
Posts 1
Joined 2006-10-02 23:17
19-year member
UID 64348
Status Offline
Then what to do under NT system?
Floor 18 Posted 2006-10-09 10:07 ·  中国 上海 普陀区 电信
银牌会员
★★★
永遠的DOS~~~
Credits 1,200
Posts 466
Joined 2005-02-01 00:00
21-year member
UID 35867
Gender Male
From 上海
Status Offline
How to accomplish this under pure DOS?
32位才是DOS未来的希望
个人网志:http://sololand.moe
Floor 19 Posted 2007-05-15 16:52 ·  中国 广东 广州 广东金万邦科技投资有限公司(新一代数据中心)IDC机房(BGP)
新手上路
Credits 4
Posts 2
Joined 2007-05-15 16:27
19-year member
UID 88610
Gender Male
Status Offline
Is there any content about mapping the CD-ROM drive as %cdrom%
Floor 20 Posted 2007-05-15 21:50 ·  中国 广东 广州 电信
中级用户
★★
脚本爱好者
Credits 238
Posts 93
Joined 2007-03-11 13:38
19-year member
UID 81417
Gender Male
From GZ
Status Offline
Originally posted by gmy at 2006-9-11 21:06:
The character judgment of "removable disk" did not take into account the case of USB-HDD (local hard disk).


Since both USB-HDD and hard disks are detected as local fixed disks, it is difficult to judge in this way, but we can consider the way of judging the newly added drive, as follows VBS:

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colEvents = objWMIService.ExecNotificationQuery ("Select * From __InstanceOperationEvent Within 5 Where " _
& "TargetInstance isa 'Win32_LogicalDisk'")
Do While True
Set objEvent = colEvents.NextEvent
If objEvent.TargetInstance.DriveType = 3 Then
If objEvent.Path_.Class = "__InstanceCreationEvent" Then
newdri = objEvent.TargetInstance.DeviceId
Wscript.Echo "The newly added disk drive letter is: " & newdri
End If
End If
Loop
Floor 21 Posted 2007-10-23 09:39 ·  中国 广东 东莞 电信
初级用户
Credits 48
Posts 20
Joined 2007-10-11 15:02
18-year member
UID 99450
Gender Male
Status Offline
I want to make a batch script that can automatically detect the drive letter of a USB flash drive when it is connected to the system and automatically perform operations like deletion, copying, or backing up. Please show me how to write the script. Previously, I wrote a relatively simple and rigid one that could only be fixed on a certain USB flash drive letter and required manual key presses. Also, when two are connected at the same time, it will go wrong because there is always a first and a second when connected, and the system displays the drive letters in a first-come-first-served manner, so often only the first connected one can be operated on...
Floor 22 Posted 2007-10-23 16:06 ·  中国 浙江 温州 乐清市 电信
初级用户
★★
Credits 109
Posts 52
Joined 2006-01-03 22:47
20-year member
UID 48392
Status Offline
Is the batch script upstairs meant to run all the time and detect USB drives at any moment?

Or is it meant to be placed on a USB drive as an autorun program for the USB drive?

The latter might be easier. You can use cd to get its path, then handle it a bit to extract the drive letter.
Floor 23 Posted 2007-10-23 16:24 ·  中国 广东 东莞 电信
初级用户
Credits 48
Posts 20
Joined 2007-10-11 15:02
18-year member
UID 99450
Gender Male
Status Offline
No, I want to make a batch script. When I need to use a USB drive, I just double-click to run it. Because I need to test many USB drives for work, and often do a lot of repetitive work, such as copying a 100M to 1000M test file, and then deleting it after the test... It's very tiring and boring... I want to make the batch processing run automatically, and all I need to do is plug in and unplug the USB drive, without having to click the mouse or keyboard again...
Floor 24 Posted 2008-08-19 16:18 ·  中国 山西 临汾 联通
新手上路
Credits 8
Posts 3
Joined 2008-08-19 12:54
17-year member
UID 123576
Gender Male
Status Offline
Additionally, what is the principle of detecting the USB flash drive drive letter? Is it only based on the disk name "Removable Disk"?

Additionally, what does DriveType mean?
Floor 25 Posted 2008-08-19 17:24 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
DriveType represents the disk type
0: "Unknown"
1: "Removable disk"
2: "Local disk"
3: "Network disk or removable hard disk"
4: "CD-ROM"
5: "RamDisk memory disk"
Floor 26 Posted 2008-08-20 11:23 ·  中国 山西 临汾 联通
新手上路
Credits 8
Posts 3
Joined 2008-08-19 12:54
17-year member
UID 123576
Gender Male
Status Offline
Can we get the U disk drive letter without using wmic? Just use internal commands.
Floor 27 Posted 2010-03-02 17:27 ·  中国 北京 电信
新手上路
Credits 6
Posts 4
Joined 2008-10-15 21:37
17-year member
UID 128475
Gender Male
Status Offline
I searched a lot online, but it seems none are perfect.
There are devcon, wmic, vbs

Is there a way to achieve the following functions using DOS commands?
Automatically identify the USB flash drive, obtain the drive letter, delete the USB flash drive, and re-identify the USB flash drive.
Forum Jump: