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-06-25 08:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Asking everyone, how can I use batch processing to determine the last drive letter? View 2,286 Replies 11
Original Poster Posted 2006-12-29 10:26 ·  中国 吉林 延边朝鲜族自治州 延吉市 联通
初级用户
Credits 69
Posts 23
Joined 2006-12-07 02:11
19-year member
UID 72775
Gender Male
Status Offline
Batch scripts that can run under DOS and correctly find the last drive letter.
Actually, I'm trying to make a Ghost automatic backup and put it on the last drive letter.
But I don't know how to specify it as the last drive letter.
It needs to work on NTFS - formatted hard drives...
Troubled seniors, please tell me, little brother is very grateful...
Also... DOS supports NTFS.
Floor 2 Posted 2006-12-29 10:45 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
In this case, you shouldn't focus on the drive letters, but rather on the number of disks and partitions.
Floor 3 Posted 2006-12-29 10:46 ·  中国 吉林 延边朝鲜族自治州 延吉市 联通
初级用户
Credits 69
Posts 23
Joined 2006-12-07 02:11
19-year member
UID 72775
Gender Male
Status Offline
The key is, I want to use it on different computers. If one computer has 3 partitions and another has 4 partitions, what should I do?
Floor 4 Posted 2006-12-29 11:03 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
So that's why you need to find a way to get the number of disks and partitions. In DOS, for example, NTFS won't have a drive letter. And the problem with the number of disks is even bigger because Ghost uses its own logic for disk sequences. It defaults to the boot hard drive as the first disk, and only when booted from other devices will it judge according to the master-slave interface of IDE. You must get the number of disks and partitions if you want to use such a command. GHOST -clone,mode=pdump,src=%sd%:%sp%,dst=%dd%:%dp%\sys.gho -sure -z9 -rb
Floor 5 Posted 2006-12-29 11:05 ·  中国 吉林 延边朝鲜族自治州 延吉市 联通
初级用户
Credits 69
Posts 23
Joined 2006-12-07 02:11
19-year member
UID 72775
Gender Male
Status Offline
Can't we directly determine the last drive letter to back it up?
Floor 6 Posted 2006-12-29 11:15 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
I don't know if ghost has such a parameter
Floor 7 Posted 2006-12-29 13:20 ·  中国 吉林 延边朝鲜族自治州 延吉市 联通
初级用户
Credits 69
Posts 23
Joined 2006-12-07 02:11
19-year member
UID 72775
Gender Male
Status Offline
Just now I've seen many methods and tried them. Except for the moderator's findcd (can't download), is there anyone who can help compile... Please everyone... As long as it can judge the last drive letter...
Floor 8 Posted 2006-12-29 13:39 ·  中国 浙江 杭州 电信
中级用户
Credits 293
Posts 30
Joined 2003-09-01 00:00
22-year member
UID 9311
Gender Male
Status Offline
@echo off
REM Determine the drive letter of the last FAT partition on the hard disk
set na=
set dif=
func -a6 >>dtemp.txt
STRINGS na=LINESIZE dtemp.txt
STRINGS dif=READ dtemp.txt,%na%
echo %dif%
Floor 9 Posted 2006-12-29 13:54 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
If you use Ghost, it has a built-in tool called GDISK.EXE. gdisk 1 displays the partition information of the first hard disk, and you can use this to retrieve.
Floor 10 Posted 2006-12-29 21:05 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Using the forum search, you can find many such posts. Take a look more to expand your ideas. Many are already closed posts.
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 11 Posted 2006-12-29 21:09 ·  中国 安徽 马鞍山 电信
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Originally posted by zahy006 at 2006-12-29 11:05:
Can't we directly determine the last drive letter to back it up?

The second floor has already said that Ghost only recognizes partition numbers, not drive letters, unless all are FAT formats (obviously, this is impossible).
I refer to others' batch scripts, and the solution is,
1. Run Ghost -dd in DOS to get the last partition number of the first hard drive (I am only looking for the first hard drive),
2. Then run the Ghost command.
Windows 一键还原
http://www.yjhy.com
Floor 12 Posted 2006-12-29 21:16 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Forum Jump: