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-08-11 10:47
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [fixed] How can a batch file open a removable hard drive? View 954 Replies 5
Original Poster Posted 2009-02-07 15:15 ·  中国 安徽 合肥 电信
初级用户
Credits 68
Posts 45
Joined 2008-11-23 17:53
17-year member
UID 131856
Gender Male
Status Offline
When I don't know the drive letter of the removable hard drive, how can I open the removable hard drive? (using a batch file)

───────────────── Moderator record ─────────────────
Executed by: HAT
Action: At the OP's request, this thread was moved from the Batch File Room to the Windows section
───────────────── Moderator record ─────────────────


[ Last edited by HAT on 2009-2-8 at 22:07 ]
Floor 2 Posted 2009-02-08 00:30 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Search this section for "removable hard drive"

Q: How can I use the forum's search function to solve my own problem?
A: Refer to: http://www.cn-dos.net/forum/viewthread.php?tid=44122#pid308085
Floor 3 Posted 2009-02-08 14:44 ·  中国 广东 东莞 电信
初级用户
Credits 41
Posts 37
Joined 2009-01-09 20:01
17-year member
UID 136255
Gender Male
From 四川南充
Status Offline
Give this a try. I tested it on my own machine and it worked, so try it. If it doesn't work, then ask someone else for help.
Actually, fastslz posted this a long time ago. I only added the last one or two lines of code; the rest of the code is from fastslzr.
@echo off
for /f "tokens=3* delims=," %%i in ('WMIC Path Win32_LogicalDisk Get DeviceID^,FileSystem^,Description /format:csv^|find /i "移动"') do call set USBDisk=%%USBDisk%% %%i
echo %USBDisk:~1%>test.txt
for /f %%a in (test.txt) Do set gdyabc=%%a
del /q test.txt
%gdyabc% && start .

[ Last edited by gdyabc on 2009-2-18 at 07:18 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
HAT +2 2009-02-08 21:51
echo @echo off>TEST.bat
Floor 4 Posted 2009-02-08 21:36 ·  中国 安徽 合肥 电信
初级用户
Credits 68
Posts 45
Joined 2008-11-23 17:53
17-year member
UID 131856
Gender Male
Status Offline
The one in post #3 works!
Many thanks!
Floor 5 Posted 2009-02-09 16:21 ·  中国 上海 杨浦区 电信
管理员
★★
Credits 389
Posts 198
Joined 2008-09-23 12:00
17-year member
UID 126405
Gender Male
Status Offline
This problem is completely solved by batch-file methods; it's not some system usage or settings problem. Why does zhangwencheng think it should be posted in the "General Operating Systems Discussion" section?

If there are no objections, I'll move it back to the "Batch File Room".
Floor 6 Posted 2009-02-13 19:13 ·  IANA 局域网IP(Private-Use)
新手上路
Credits 14
Posts 14
Joined 2009-02-09 15:18
17-year member
UID 138402
Gender Male
Status Offline
Post #3 is awesome, there's no end to learning...
Forum Jump: