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 ]
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:
SET NUM=25
:CHECK
COUNT.COM NUM -
HDRIVE.EXE|NSET.COM LASTPART=$%NUM%
IF "%LASTPART%"=="" GOTO CHECKHDRIVE.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 ]
