中国DOS联盟论坛

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-09-06 07:00
47,812 topics / 349,914 posts / today 0 new / 48,268 members
DOS启动盘 & LOGO技术 (启动盘室) » Understanding of the setramd.bat command line in the DOS boot disk
Printable Version  3,209 / 5
Floor1 booyer Posted 2006-12-06 13:22
新手上路 Posts 2 Credits 5
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
Floor2 bc12060101 Posted 2006-12-06 21:47
银牌会员 Posts 712 Credits 1,455
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!
Floor3 jzzyl Posted 2007-01-16 09:52
初级用户 Posts 38 Credits 90
Thanks to the LZ, I've gained new knowledge again, heh heh. Hope there'll be more next time.
Floor4 dongam Posted 2007-01-18 10:27
初级用户 Posts 31 Credits 70
Popular science knowledge lecture~ I like it!
Floor5 888168 Posted 2007-01-21 08:21
新手上路 Posts 9 Credits 18
Thanks
Floor6 tnt844 Posted 2010-02-21 22:00
初级用户 Posts 21 Credits 41
The benefits of searching old posts, well, thank you for the楼主's sharing.

(注:“楼主”是中文特定词汇,在英文中通常保留拼音“lz”或直接使用“the poster of the thread”,但根据要求如果不翻译则保留原文,这里原句中“楼主”未翻译,整体按照要求翻译为上述内容)
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023