![]() |
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-08-10 18:48 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » How to make a batch file automatically identify which partition a certain drive letter is in under DOS? |
| Printable Version 7,721 / 24 |
| Floor1 walu | Posted 2004-04-22 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Foreword: When using the GHOST command-line form under DOS, when restoring an image to a partition, GHOST will automatically recognize the D drive as the second partition, the E drive as the third partition, and so on. However, if there are NTFS-formatted partitions and hidden partitions in between, the E drive is not the third partition, and the F drive is not the fourth partition. Example: If the C drive is a FAT32 partition, the D drive is a hidden partition, the E drive is an NTFS partition, and the F drive is a FAT32 partition, the D drive and E drive will not be displayed under DOS, and the F drive becomes the D drive. Problem proposal: How to make the batch processing automatically recognize the D drive (actually the F drive) as the fourth partition in the hard drive instead of the second partition under DOS?
|
|
| Floor2 Climbing | Posted 2004-04-22 00:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Are you overcomplicating the problem? GHOST never relies on drive letters for restoration; it can be said that it only recognizes partitions. Think carefully about what you want to do, and then decide how to do it.
|
|
| Floor3 walu | Posted 2004-04-22 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Simply put, I want to package the boot files such as IO.SYS, COMMAND.COM and the GHOST.EXE file required for the IBM one-key recovery partition into a *.gho file using GHOST, then use PQMAGIC to divide a primary partition (such as drive E, volume label SYS_GHOST) on the hard drive, and then restore the *.gho file to drive E using GHOST (of course, I just want this process to be automatically executed in DOS). Then I can press the F11 key to restore the system when booting.
However, during the process of restoring the *.gho file to drive E with GHOST, since GHOST does not use the drive letter as the basis for restoration, it only recognizes the partition. If there are no hidden partitions and NTFS format partitions on the hard drive, the SYS_GHOST partition (drive E) is the third partition; but if drive D is an NTFS format partition, this SYS_GHOST partition becomes drive D in DOS. So how to make DOS recognize which partition the SYS_GHOST partition is becomes complicated. |
|
| Floor4 ggtt | Posted 2004-04-23 00:00 |
| 初级用户 Posts 14 Credits 146 | |
|
I can't understand what you're trying to say. Hope the following is helpful
rem d:\ghost.exe -clone,mode=pload,src=e:\recover.gho:1,dst=1:1 -sure -rb rem -sure ------Indicates to answer YES to all questions rem -rb ------Indicates automatic reboot after completion rem -fx ------After GHOST finishes working, it doesn't display (Press Ctrl-Alt-Del to reboot), but directly returns to the DOS state mode=pload Restore partition dst=1:1 First hard disk, first partition If it's not easy to determine with src=, you can use if exist to test one by one |
|
| Floor5 walu | Posted 2004-04-24 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Alas, you all don't understand. Fortunately, Rao Xiaochao, the author of One-key Recovery Elf, can understand and is preparing to develop a program with such a function.
|
|
| Floor6 Tamm | Posted 2004-04-24 00:00 |
| 中级用户 Posts 64 Credits 397 | |
|
After looking at it for a long time, I still don't quite understand what you mean.
Hope these methods are useful to you: 1: If you know in advance which partition it is in the physical hard drive arrangement for the purpose of the operation you want to perform, then there will be no problem at all when restoring with GHOST, because when GHOST restores from the image file to the partition, it uses the format of "disk:partition" to specify the destination partition. (For example, DST=1:3) 2: If you don't know which physical partition the partition is, but you know what the volume label of the partition is, then you can use the two tools Gdisk and lmod together to find out which physical partition it is. The specific operation is a bit complicated, but it is still feasible. Briefly talk about the process: Gdisk 1 >temp.txt Get the partition list of the specified hard drive to a temporary text find "label" temp.txt >temp1.txt Extract the relevant partition line using the volume label as the keyword Analyze the information in this line with lmod (the specific operation is omitted) Because the partition list obtained by Gdisk has a fixed format So lmod can be used for comprehensive analysis to get the desired information. Determine whether it is a primary partition or a logical partition by finding whether this line is "PRIMARY" or "LOGICAL". Because the numbering of partitions in Gdisk is different from that in Ghost. There will be an "EXTENDED" extended partition numbered between the primary partition and the logical partition in Gdisk. So, the partition number displayed by Gdisk needs to be processed before being used in Ghost. In fact, the specific processing is also easy, that is: if it is a primary partition, just use the number directly; if it is a logical partition, just subtract 1 from the number. By modifying the above method, you can also use LMOD to check which partition the known drive letter is in the physical partition... (Not applicable to NTFS partitions) |
|
| Floor7 Tamm | Posted 2004-04-25 00:00 |
| 中级用户 Posts 64 Credits 397 | |
|
@ECHO OFF
gdisk 1 > %temp%\temp.txt TFind /f30,10 "label" %temp%\temp.txt >%temp%\temp1.txt type %temp%\temp1.txt | lmod set type=set part= >%temp%\temp.bat call %temp%\temp.bat if %type%==LOGICAL count part -1 set type= del %temp%\temp*.* :end The above is a batch script to find the partition number through the volume label (just change the third line "label" to the actual volume label). If you want to find the partition number through the drive letter, replace the third line in the above batch script with the following line: Tfind /f2,2 "E:" %temp%\temp.txt >%temp%\temp1.txt (taking finding drive E: as an example here) The execution result writes the partition number into variable %part%. This batch script uses Norton's Gdisk and three small programs by Horst Schaeffer: LMOD TFind COUNT |
|
| Floor8 willsort | Posted 2004-04-25 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re walu:
So how to make DOS recognize which partition the SYS_GHOST is becomes complicated. Do you mean it can be expressed like this - how to determine which partition of the hard disk the disk recognized by the DOS system is, and then place this partition number in the command line parameters for GHOST to call? |
|
| Floor9 walu | Posted 2004-04-25 00:00 |
| 高级用户 Posts 201 Credits 916 | |
The following is a quote from willsort on 2004-4-25 10:52:26: willsort is really brilliant! That's the very meaning. In terms of batch processing, willsort and Climbing are both top-notch experts! Can this problem be solved through batch processing? |
|
| Floor10 walu | Posted 2004-04-26 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
The problem has been basically solved, thanks to Brother Tamm!
|
|
| Floor11 walu | Posted 2004-04-26 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
For the sentence by Brother Tamm: "If it's a primary partition, just use the number directly; if it's a logical partition, just subtract 1 from the number" (this sentence won't be wrong if you use PQMAGIC to split a primary partition on the first primary partition). There is still an error. Because if you use PQMAGIC to split a primary partition on an extended partition, directly using the number will cause an error, because although GDISK recognizes that this is a primary partition, it still includes it in the logical partitions to count the partition number.
|
|
| Floor12 Tamm | Posted 2004-04-26 00:00 |
| 中级用户 Posts 64 Credits 397 | |
The following is a quote from walu on 2004-4-26 11:46:22: I don't understand... You said "... If you use PQMAGIC to divide a primary partition on an extended partition ..." How can you create a primary partition on an extended partition...? Do you mean using PQ to shrink the extended partition, and then create a second primary partition in the part left behind after the extended partition on the hard disk? That is, like this?: I'm sorry, I didn't consider such a situation when I proposed this plan. If that's the case, Gdisk will use the following numbering: 1 First primary partition 2 Second primary partition 3 Extended partition 4... Logical partitions under the extended partition But I don't know how Ghost uses the partition number in such a situation...... |
|
| Floor13 walu | Posted 2004-04-26 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Brother Tamm, I have found another program to replace GDISK, which is perfect. But after executing this program, it all appears "Press any key to continue...", that is, it requires pressing any key to continue executing the subsequent program. I don't want to use manual key pressing, and I want to execute it and then automatically continue executing the subsequent program. How should I do it?
|
|
| Floor14 Tamm | Posted 2004-04-26 00:00 |
| 中级用户 Posts 64 Credits 397 | |
|
Can you kindly give some advice...
What was used as a substitute? ^_^ |
|
| Floor15 walu | Posted 2004-04-26 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
It is a file with only 27K. See the attachment Open the attachment
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |