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 13:48
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to get the drive letter of the last partition of the local hard disk under DOS? View 2,555 Replies 12
Original Poster Posted 2005-10-05 14:03 ·  中国 河北 沧州 任丘市 华北油田网络
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
In the process of computer maintenance, I often encounter such a problem:
The machine being maintained once had a system image file made by GHOST, but I don't know which partition and which directory on the hard disk it is placed in. So I am considering that if I compile a batch file, let it automatically obtain all the drive letters of the current hard disk, and then use the command dir /s/e "drive letter":\*.gho to find the image file. But now I don't know which program under DOS has this function, which can list all the partition drive letters on the current hard disk.
I remember that a brother once asked a similar question on the forum. At that time, a expert provided him with a small program under DOS, which can very conveniently output all the partition numbers of the current hard disk in the form of one partition number per line to a text file. At that time, I didn't pay attention, but now I can't find that post at all. Does that brother know, or is there another good way to solve it? Please tell me, thank you!

[ Last edited by willsort on 2005-10-6 at 23:02 ]
Floor 2 Posted 2005-10-05 15:11 ·  中国 山西 太原 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re sglxy:

For your situation, you can consider using locate to locate the path of the gho file. This program can be found in the super startup disk of this forum. The usage is similar to:

locate *.gho /n /f1 /b9:"ghost ...." > _restore.bat
call _restore.bat ...
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 3 Posted 2005-10-05 18:00 ·  中国 河北 沧州 任丘市 华北油田网络
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
Thanks to teacher willsort for the explanation. The locate program is really something I've never seen before. Maybe I've only used "Super Boot Disk" before and never paid attention to it.
Floor 4 Posted 2005-10-05 19:45 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 5 Posted 2005-10-05 19:50 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 6 Posted 2005-10-05 20:42 ·  中国 河北 沧州 任丘市 华北油田网络
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
Thank you, may I ask how to use the ncd command in batch processing?
Floor 7 Posted 2005-10-06 09:13 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 8 Posted 2005-10-06 12:23 ·  中国 河北 沧州 任丘市 华北油田网络
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
Originally posted by willsort at 2005-10-5 03:11 PM:
Re sglxy:

For your situation, you can consider using locate to locate the path of the gho file. This program can be found in the super startup disk of this forum. Usage similar to:

locate *.gho / ...





Teacher willsort, in the line of command you listed:
locate *.gho /n /f1 /b9:"ghost ...." > _restore.bat
Does it mean that the search result of "locate *.gho /n /f1 /b9:" is output as a variable to the ghost command line? Then what is the variable name?
Floor 9 Posted 2005-10-06 15:37 ·  中国 山西 太原 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re: sglxy:

This sentence means embedding the output of locate into the ghost command line, adding a line @echo off and then outputting, we redirected this output to the batch _restore.bat, and then we called it.

But considering that locate will default to taking the path of the searched image file as the first parameter, and the ghost command line may not allow this usage, so saving the path to an environment variable may be a more appropriate usage. As follows:


locate *.gho /n /f1 /b:"set _ghofile=" > _setghof.bat
call _setghof.bat
del _setghof.bat
ghost -clone...%_ghofile%...
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 10 Posted 2005-10-06 22:18 ·  中国 河北 沧州 联通
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
I understand now, Teacher willsort, thank you!
Floor 11 Posted 2005-10-09 08:50 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 12 Posted 2005-10-09 12:29 ·  中国 河北 沧州 任丘市 华北油田网络
中级用户
★★
MS-DOS爱好者
Credits 397
Posts 87
Joined 2002-12-15 00:00
23-year member
UID 517
Gender Male
Status Offline
This program can be found in the super boot disk of this forum.
Floor 13 Posted 2005-10-09 18:33 ·  中国 安徽 宿州 泗县 电信
银牌会员
★★★
Credits 1,339
Posts 595
Joined 2004-05-26 00:00
22-year member
UID 25306
Gender Male
From 安徽 宿州
Status Offline
What if the .gho file is hidden? Can Locate be used? Instead of using an automatic method, it's better to use a manual method: Dir d:\.gho/s or Dir d:\.gho/s/a. This is for searching the D drive, and the method for searching other drives is the same.
Forum Jump: