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-22 22:07
中国DOS联盟论坛 » DOS启动盘 & LOGO技术 (启动盘室) » Understanding of the setramd.bat command line in the DOS boot disk View 3,083 Replies 5
Original Poster Posted 2006-12-06 13:22 ·  中国 广西 南宁 电信
新手上路
Credits 5
Posts 2
Joined 2006-11-22 11:39
19-year member
UID 71374
Gender Male
Status Offline
Understanding of the setramd.bat command line. If there are any mistakes, please correct them, masters!

@echo off
a:\findramd
:: Run findramd in drive a to find the virtual drive.
if errorlevel 255 goto no_ramdrive
:: If the return value of executing findramd is 255, it means there is no virtual drive. Then execute no_ramdrive to display the information that the virtual drive does not exist.
if not errorlevel 3 goto no_ramdrive
:: If the return value of executing findramd is not 3 (when the return value is 3, the virtual drive exists), it means there is no virtual drive. Then execute no_ramdrive to display the information that the virtual drive does not exist.
goto do_shift
:: If the above two situations do not hold (indicating that the virtual drive exists), then execute do_shift to start setting the drive letter of the virtual drive.

:loop
:: Determine the drive letter of the virtual drive.
if errorlevel %1 goto no_shift
:: Because after shift is executed, the return value is the value represented by parameter %1. If the value represented by parameter %1 can be returned as the return value, it means that parameter %1 is not empty. Then execute no_shift to assign a drive letter to the virtual drive.

:do_shift
:: Start setting the drive letter of the virtual drive.
set cdrom=%2
:: Set the string cdrom (the drive letter of the CD-ROM. Determined by mscdex /L:%cdrom%) corresponding to parameter %2. Please note: At this time, the drive letter assigned to the CD-ROM is determined by the hardware and does not include the virtual drive established by ramdrive. Because the default drive letter allocation of the system is: floppy drive (a), floppy drive (b), hard disk, CD-ROM. So, if there is only one partition on the hard disk, the hard disk (c), CD-ROM (d). If there are multiple partitions on the hard disk, the CD-ROM drive letter is pushed back. If there is no hard disk, the CD-ROM (c). When there is a virtual drive, the virtual drive is arranged between the hard disk and the CD-ROM, so the CD-ROM drive letter will be moved back by one position.
shift
:: Shift the parameters by one position to the left (that is, make the drive letters corresponding to parameters %1 and %2 move forward by one position).
shift
:: Shift the parameters by one position to the left (that is, make the drive letters corresponding to parameters %1 and %2 move forward by one position again).
if not %1*==* goto loop
:: After two left shifts, if parameter %1 is still not empty (that is, %1*==* is not established), it means the virtual drive exists. Then execute loop to determine the drive letter of the virtual drive.
goto no_ramdrive
:: After two left shifts, if parameter %1 is empty (that is, %1*==* is established), it means the virtual drive does not exist. Then execute no_ramdrive to display the information that the virtual drive does not exist.

:no_shift
:: Assign a drive letter to the virtual drive.
set ramd=%2
:: Let the drive letter of the virtual drive take the drive letter corresponding to parameter %2 (that is, the drive letter that the CD-ROM obtained before the virtual drive was established).
goto success
:: Execute success to display the information that the virtual drive is successfully established.

:no_ramdrive
:: No virtual drive exists or cannot be established (some prompt information can be set).

:success
:: Display the information that the virtual drive is successfully established
Floor 2 Posted 2006-12-06 21:47 ·  中国 河南 洛阳 电信
银牌会员
★★★
Credits 1,455
Posts 712
Joined 2006-01-20 10:26
20-year member
UID 49246
Status Offline
Thank you, the original poster!
Some questions that I didn't understand before are now clear after the original poster's explanation.
Thank you here!
Floor 3 Posted 2007-01-16 09:52 ·  中国 辽宁 锦州 联通
初级用户
Credits 90
Posts 38
Joined 2007-01-16 08:12
19-year member
UID 76668
Gender Male
Status Offline
Thanks to the LZ, I've gained new knowledge again, heh heh. Hope there'll be more next time.
Floor 4 Posted 2007-01-18 10:27 ·  中国 陕西 西安 电信
初级用户
Credits 70
Posts 31
Joined 2007-01-08 07:20
19-year member
UID 75810
Gender Male
Status Offline
Popular science knowledge lecture~ I like it!
Floor 5 Posted 2007-01-21 08:21 ·  中国 湖北 黄石 大冶市 电信
新手上路
Credits 18
Posts 9
Joined 2007-01-15 03:57
19-year member
UID 76545
Gender Male
Status Offline
Thanks
Floor 6 Posted 2010-02-21 22:00 ·  中国 广西 柳州 联通
初级用户
Credits 41
Posts 21
Joined 2009-06-17 06:31
17-year member
UID 147604
Gender Male
Status Offline
The benefits of searching old posts, well, thank you for the楼主's sharing.

(注:“楼主”是中文特定词汇,在英文中通常保留拼音“lz”或直接使用“the poster of the thread”,但根据要求如果不翻译则保留原文,这里原句中“楼主”未翻译,整体按照要求翻译为上述内容)
Forum Jump: