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-08-01 15:48
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Can a batch file automatically find and enter a certain CD-ROM to run a specific View 1,704 Replies 11
Original Poster Posted 2005-02-01 00:00 ·  中国 福建 泉州 电信
初级用户
Credits 154
Posts 15
Joined 2005-01-31 00:00
21-year member
UID 35835
Gender Male
Status Offline
I want to make a bootable CD, placing both the operating system's ghost backup and the ghost software on the CD. Since the bootable CD has a dual identity, the drive letter displayed after booting is drive A, while the ghost backup is on the CD drive, and it's inconvenient to switch drive letters when using it.

I thought that if I compile an independent ghost.bat and put it into the boot files, generally this CD is still used as a boot disk, and when I need to restore the ghost backup, I execute this file. Can the DOS system automatically execute the ghost file in the CD drive?

Because the drive letter of the CD drive on each computer varies greatly due to the different number of partitions. Some people have drive D, while some have drive G or others, and some computers even have an additional burner. I would like to ask all experts: How can I make DOS automatically find the CD drive and locate the disk where the CD is? How should this batch processing be written? Thanks in advance.
Floor 2 Posted 2005-02-01 00:00 ·  中国 广东 广州 白云区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Method 1 (Using FINDCD.EXE):

There is a small program FindCD.exe in Wengier's MSDOS 7.1 boot disk. With it, it's easy to confirm the CD - ROM drive letter! When you run it, it will automatically store the CD - ROM drive letter in the %CDROM% environment variable. Then the GHOST.BAT can be written in a few lines (assuming the GHOST program is stored in the \GHOST folder on your CD - ROM):

@echo off
findcd
%cdrom%
cd\ghost
ghost

Method 2 (Modifying AUTOEXEC.BAT):

The MSCDEX or SHSUCDX command to drive the CD - ROM can set the CD - ROM to a specific drive letter. For example:

MSCDEX /D:IDE-CD /L:Z
or
SHSUCDX /D:IDE-CD,Z

No matter how many partitions the hard disk has, or even if there is no hard disk, you can set the CD - ROM to Z:. Then the batch processing is simpler:

@echo off
z:
cd\ghost
ghost

[ Last edited by JonePeng on 2005-11-29 at 13:16 ]
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 3 Posted 2005-02-02 00:00 ·  中国 福建 泉州 电信
初级用户
Credits 154
Posts 15
Joined 2005-01-31 00:00
21-year member
UID 35835
Gender Male
Status Offline
Great! Thanks to Brother JonePeng for the guidance.
Floor 4 Posted 2005-02-02 00:00 ·  中国 海南 三亚 电信
初级用户
Credits 187
Posts 21
Joined 2005-01-22 00:00
21-year member
UID 35554
Gender Male
Status Offline
If the CD - ROM is set to Z: it will bring some troubles if there are several CD - ROMs. It is better to set the CD - ROM to a more appropriate letter.
Floor 5 Posted 2005-02-02 00:00 ·  中国 福建 福州 电信
元老会员
★★★
农民
Credits 2,903
Posts 991
Joined 2003-07-23 00:00
23-year member
UID 7391
Gender Male
From 福建省
Status Offline
You can use FoundCD to put the drive letter of the CD into a variable, and then use %CDROM% to directly jump to the CD. The FoundCD program can be found in Wengier's bootable disk.
艰难奋长戟,万古用一夫

中国DOS联盟 http://www.cn-dos.net 欢迎大家来共同学习
我的MSN&E-Mail cn_archer@hotmail.com QQ 56049418
Floor 6 Posted 2005-02-02 00:00 ·  中国 福建 泉州 电信
初级用户
Credits 154
Posts 15
Joined 2005-01-31 00:00
21-year member
UID 35835
Gender Male
Status Offline
Thanks to the instructor's teachings. But I'm a newbie, and I'm most afraid of variables. Can you explain it in detail? Of course, if you can write out the entire batch file like the brother above, then it's the best, and I can also learn while imitating. Thanks. Another: Thanks to brother mtx from 4th floor for the reminder.
Floor 7 Posted 2005-02-03 00:00 ·  中国 福建 福州 电信
元老会员
★★★
农民
Credits 2,903
Posts 991
Joined 2003-07-23 00:00
23-year member
UID 7391
Gender Male
From 福建省
Status Offline
The JonePeng on the second floor has already made it very clear. Just follow his example to apply it. I didn't read his post carefully when I posted yesterday. I'm ashamed.
艰难奋长戟,万古用一夫

中国DOS联盟 http://www.cn-dos.net 欢迎大家来共同学习
我的MSN&E-Mail cn_archer@hotmail.com QQ 56049418
Floor 8 Posted 2006-04-21 13:52 ·  中国 安徽 铜陵 移动
中级用户
★★
Credits 230
Posts 104
Joined 2006-04-21 12:22
20-year member
UID 54192
Gender Male
Status Offline
Great minds, I'm learning from you!
Floor 9 Posted 2006-04-21 13:58 ·  中国 广东 深圳 电信
初级用户
★★
Credits 133
Posts 57
Joined 2006-03-15 23:12
20-year member
UID 52128
Status Offline
Learning
Floor 10 Posted 2006-04-28 02:17 ·  中国 上海 宝山区 电信
初级用户
Credits 46
Posts 17
Joined 2006-04-27 00:13
20-year member
UID 54517
Gender Male
Status Offline
It's not to that point yet!
Floor 11 Posted 2006-04-29 11:51 ·  中国 四川 绵阳 电信
高级用户
★★
Credits 587
Posts 282
Joined 2006-04-10 03:40
20-year member
UID 53599
Gender Male
Status Offline
When there are multiple CD - ROM drives, you can assign drive letters to the CD - ROM drives respectively, and there won't be any confusion.
Floor 12 Posted 2006-05-04 21:34 ·  中国 重庆 电信
新手上路
Credits 15
Posts 6
Joined 2006-04-23 13:21
20-year member
UID 54318
Gender Male
From 河北
Status Offline
Study hard, thank you everyone!
Forum Jump: