![]() |
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-08-18 14:39 |
47,814 topics / 349,908 posts / today 1 new / 48,259 members |
| DOS疑难解答 & 问题讨论 (解答室) » (Solved) How to get the drive letter of a USB flash drive in a DOS batch file? |
| Printable Version 1,264 / 5 |
| Floor1 chenqiguang | Posted 2006-12-26 23:13 |
| 初级用户 Posts 10 Credits 22 | |
|
After booting a DOS boot disk made from a USB flash drive into MS-DOS7.1, on some machines its drive letter is “A:”, while on other machines its drive letter is “C:”.
In the batch file autoexec.bat on the USB flash drive, when the drive letter of the USB flash drive is “A:”, program A needs to be executed; when the drive letter of the USB flash drive is “C:”, program C needs to be executed. How can I get the drive letter of the USB flash drive in the DOS batch file autoexec.bat to make this work? Thanks in advance! Solved using the method introduced in post #4. Thanks again for the answers from the helpful members! [ Last edited by chenqiguang on 2006-12-27 at 10:28 PM ] |
|
| Floor2 zplinux | Posted 2006-12-26 23:53 |
| 新手上路 Posts 4 Credits 7 From 四川成都 | |
|
I can't answer the OP's question.
But I can provide one method I use for reference: In “autoexec.bat”, set the program execution path like this: SET PATH=A:\dos_tool\;A:\;\C:\dos_tool\;C:\ After that, when executing a program, just write the program name directly. For example: LH CTMOUSE LH DOSKEY There is no need to call the program with an absolute path. That will do. As for the reason for the difference between A and C drives, it is related to the way the bootable USB flash drive is made. With the zip/FDD method, after booting it becomes drive A With the HDD method, after booting it becomes drive C. If anything is incomplete, you can contact me by E-mail for discussion. zplinux@21cn.com |
|
| Floor3 chenqiguang | Posted 2006-12-27 00:22 |
| 初级用户 Posts 10 Credits 22 | |
|
The program to be executed needs parameters, so an absolute path must be used.
|
|
| Floor4 lianjiang2004 | Posted 2006-12-27 03:48 |
| 金牌会员 Posts 1,884 Credits 3,946 | |
|
You can put a signature file in the root directory of your USB flash drive and use it for detection.
Suppose the file is myudisk.000 if not exit a:\myudisk.000 goto c a goro exit :c c :exit [ Last edited by lianjiang2004 on 2006-12-27 at 03:50 AM ] |
|
| Floor5 chenqiguang | Posted 2006-12-27 05:09 |
| 初级用户 Posts 10 Credits 22 | |
Originally posted by lianjiang2004 at 2006-12-27 03:48: I'll reply again after testing it. |
|
| Floor6 zihan | Posted 2006-12-30 00:18 |
| 初级用户 Posts 24 Credits 66 | |
|
This problem is very simple. I also ran into it when making a bootable USB flash drive. The USB flash drive was originally ZIP, but some motherboards insist on recognizing it as drive C: after booting, so the drive letter of the boot disk has to be identified.
There are two methods: 1. Signature detection, FOR %%A IN (A: C:) DO IF EXIST DOS\DRIVERS\NUL SET BDR=%%A (DOS\DRIVERS is a directory on my USB flash drive)This way the boot drive letter can be set into the %BDR% variable. 2. Use a small tool: bootdrv.com. After running it, it will return an errorrlevel value, and by testing that you can know the boot drive letter. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |