![]() |
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-15 13:37 |
47,813 topics / 349,903 posts / today 1 new / 48,257 members |
| DOS疑难解答 & 问题讨论 (解答室) » [Detailed Explanation] Cleverly Getting the Last Hard Disk Drive Letter under Pure DOS |
| Printable Version 1,621 / 3 |
| Floor1 chishingchan | Posted 2009-10-12 15:45 |
| 银牌会员 Posts 538 Credits 1,284 | |
|
I’m forgetful, so I’m posting this. On one hand it’s convenient for others, and on the other hand I’m making notes for myself.
Required tools: http://upload.cn-dos.net/img/1715.rar Included files: COUNT.COM COUNT.TXT HDRIVE.EXE NSET.COM NSET.TXT Feature: does not generate (third-party) files Complete example: HDRIVE.EXE is used to get recognizable hard disk drive letters. When a hard disk partition format is not FAT32, it cannot recognize it. For example, suppose the current hard disk partitions are as follows: C:FAT32 D:FAT32 E:NTFS F:FAT32 Run: C:\>HDRIVE.EXE and press Enter, then it returns: C: D: E: The original E:cannot be recognized, so F:takes its place. That means the E:here is the F:drive under Windows. The function of NSET.COM is to define the passed parameters as its self-recognized $?, and it can also define variables. For example: HDRIVE.EXE|NSET.COM LASTPART=$%NUM% HDRIVE.EXE passes the parameters C:D:E:to NSET.COM, which means: C: D: E: $1 $2 $3 LASTPART=$%NUM% When the value of NUM is 4, then LASTPART=empty (empty means if this variable exists, then delete this variable) When the value of NUM is 3, then LASTPART=E: Why define NUM=25? Because the loop first subtracts 1 from it (improved after a reminder from 523066680) Because hard disk drive letters are counted starting from C:, 24 represents the Z:drive letter. COUNT.COM is used to perform arithmetic on the value of a numeric variable COUNT.COM NUM - means subtract 1 from the value of the variable IF "%LASTPART%"=="" GOTO CHECK When the value of the variable LASTPART is empty, that means the number for the last drive letter has not yet been reached, so it loops, until the value of NUM is 3, at which point the value represented by $3, E:, is assigned to the variable LASTPART. At that time LASTPART is no longer empty, and the loop ends. [ Last edited by chishingchan on 2009-10-19 at 12:55 ] |
|
| Floor2 523066680 | Posted 2009-10-12 17:54 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
hi ~ this is the first time I’ve seen you post in 2009.
Do you still remember me~ http://www.cn-dos.net/forum/viewthread.php?tid=39780 What you said there really encouraged me ^_^ ----------------------------------------- By the way, you said it is counted starting from C, so shouldn’t Z be 26? [ Last edited by 523066680 on 2009-10-12 at 17:59 ] |
|
| Floor3 chishingchan | Posted 2009-10-12 22:28 |
| 银牌会员 Posts 538 Credits 1,284 | |
Originally posted by 523066680 at 2009-10-12 05:54 PM: Right! Thanks for the reminder! I can’t believe such a low-level mistake happened to me. Haha! Can’t help it! I’ve got too many projects! What I’m into now is VBS. I only research DOS when I need to use it now, so I get forgetful, and that’s why I posted this mistaken article! |
|
| Floor4 33445566 | Posted 2009-10-13 20:54 |
| 初级用户 Posts 16 Credits 29 | |
|
It would be even better to add a batch file for getting the last hard disk drive letter under pure DOS
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |