![]() |
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-10-24 19:41 |
47,815 topics / 349,928 posts / today 0 new / 48,288 members |
| DOS疑难解答 & 问题讨论 (解答室) » How to implement automatically adjusting partition size with a DOS program??? |
| Printable Version 13,860 / 98 |
| Floor76 mewf | Posted 2004-03-18 00:00 |
| 中级用户 Posts 55 Credits 344 | |
|
for Windows is mainly for DOS and cannot run under win9x/win2000/winXP! So I thought of using the Windows version! Also, can you tell me an installation monitoring software! Thank you.
|
|
| Floor77 Climbing | Posted 2004-03-18 00:00 |
| 铂金会员 Posts 2,753 Credits 6,964 From 河北保定 | |
|
To install monitoring software, you can use RegShot. Take snapshots of the registry and drive C before and after installing PQ, then compare the two snapshots.
|
|
| Floor78 mewf | Posted 2004-03-19 00:00 |
| 中级用户 Posts 55 Credits 344 | |
|
Thanks
|
|
| Floor79 walu | Posted 2004-03-19 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Hello, Brother Climbing!
Because I am not familiar with scripts and English, I want to make some changes to your script according to my own wishes, but I can't succeed. I want to achieve this: first detect the last partition, if there is enough space (that is, it meets the conditions), then divide it; if there is not enough space, then go to detect the first partition (that is, the primary partition), if there is enough space, then divide it; if there is not enough space, then cycle from the second-to-last partition forward to free up the required space. That is to say, in the original script, when the last partition is detected to have insufficient space, it turns to the second-to-last partition, but now I require to turn to the first primary partition first, and then turn to the second-to-last partition. Why do this? Because freeing up space from the second-to-last partition for the last partition causes the partition to be very slow due to the large amount of data to be moved; while the first partition C drive of many computers is often relatively large, such as 10G. If 2G of space is freed from its tail, no data needs to be moved, which speeds up the partition. Of course, when partitioning the C drive, sufficient remaining space will be considered for it. IF GetUnusedAmount > PriSize + 2048 Then That is, the unused space GetUnusedAmount must be more than the partitioned space PriSize by 2G to allow operation. |
|
| Floor80 Climbing | Posted 2004-03-20 00:00 |
| 铂金会员 Posts 2,753 Credits 6,964 From 河北保定 | |
|
What you said also makes sense, but the primary partition established this way is not at the end of the hard drive, but behind the first primary partition. Of course, the primary partition established in this way does not affect the installation of one-key recovery, and it should be feasible. According to your requirement, you need to first check whether the space of the last partition is sufficient. If not, then check the first partition. If it is still not sufficient, operate according to my V3 script, right?
The following is the script modified according to your needs: // Allow the user to manually restart the computer after the operation, otherwise it will automatically restart the computer Allow Manual Reboot // By default, do not detect bad sectors to improve operation speed Set Default Bad Sector Test State OFF // Select the first hard drive Select Disk 1 // Select the first partition Select Partition First Dim PriSize // Detect the used space of the first partition, set PriSize to 1/2 of its used space plus 200M, otherwise it may not be enough PriSize = GetUsedAmount / 2 + 200 // Detect the number of primary partitions on the current hard drive Dim PriNum Dim i i = 1 PriNum = 0 Select Partition FIRST DO WHILE i < GetTotalPartitions IF IsPrimary Then PriNum = PriNum + 1 End If Select Partition Next i = i + 1 Loop IF IsPrimary Then PriNum = PriNum + 1 End If // Detect whether there is an extended partition on the hard drive, if there is, it is also counted as a primary partition dim ExtNum ExtNum = GetPartitionNumber Extended If ExtNum 0 Then PriNum = PriNum + 1 End If // Only continue if the number of primary partitions is less than 4 IF PriNum = PriSize Then Resize Space After PriSize // Select the last unallocated space (the one just freed) Select Unallocated After Selected Partition // Create a partition of the specified size at the end of the hard drive, the volume label is SYS_GHOST, of course, you can modify the label according to the actual situation. Create /FS=FAT32 /LABEL="SYS_GHOST" // Convert this partition to a primary partition Convert To Primary bDone = 1 End If // If the space of the last partition is not enough, then check whether the space of the first partition is enough. If it is enough, repeat the above operation. If bDone = 0 Then Select Partition First Check Resize Larger Max If GetUnusedAmount >= PriSize + 2048 Then Resize Space After PriSize // Select the last unallocated space (the one just freed) Select Unallocated After Selected Partition // Create a partition of the specified size, the volume label is SYS_GHOST, of course, you can modify the label according to the actual situation. Create /FS=FAT32 /LABEL="SYS_GHOST" // Convert this partition to a primary partition Convert To Primary bDone = 1 End If End If // If the above two operations are not successful, perform the third operation, which is also the most complex operation, mainly manifested in the longest time consumption If bDone = 0 Then // If there is an extended partition, select the extended partition and let it occupy all the unallocated space before and after If ExtNum 0 Then Select Disk 1 Select Partition Extended Resize Max End if // dOperPnum is used to save how many partitions have been operated Dim dOperPnum dOperPnum = 0 // bMove is used to judge whether space freeing operation has been performed. If yes, it is the basis for subsequent space movement judgment Dim bMove bMove = 0 // dLastOpPar saves the partition number of the last operation Dim dLastOpPar // If the current number of unallocated spaces meets the need, there is no need to perform space reallocation operation If GetTotalUnallocatedSpaces < PriSize Then // Select the last partition and judge whether it is a primary partition Select Partition Last Check // FreeSpace is used to save the freed space Dim FreeSpace FreeSpace = 0 // NeedSpace is used to save how much space still needs to be freed Dim NeedSpace NeedSpace = PriSize Dim dTmp dTmp = 0 // Loop from the last partition to free the required space i = 0 Do While FreeSpace = NeedSpace Then // Change the size of this partition, free the space of the required size (that is, the value saved in the NeedSpace variable) behind it Resize Space After NeedSpace FreeSpace = FreeSpace + NeedSpace bMove = 1 Else // If the remaining space of this partition is greater than 100M, reduce the size of this partition by the size of unused space minus 100M If GetUnusedAmount > 100 Then dTmp = GetUnusedAmount - 100 Resize Space After dTmp FreeSpace = FreeSpace + dTmp NeedSpace = PriSize - FreeSpace bMove = 1 End If End If i = i + 1 dOperPnum = dOperPnum + 1 // If the loop reaches the first partition but the space is still insufficient, directly exit the loop If i < GetTotalPartitions Then Select Partition Previous Check dLastOpPar = GetPartitionNumber Next Else If FreeSpace < PriSize Then dLastOpPar = GetPartitionNumber First Exit Loop End If Loop End If //If GetTotalUnallocatedSpaces < PriSize // If there is no partition segmentation operation, there are two reasons: 1. Insufficient disk space; 2. Unallocated space is enough If bMove = 0 Then dLastOpPar = GetPartitionNumber First dOperPnum = GetTotalPartitions Select Partition First Move Left Max Else // Start to move the space freed in the previous loop backwards Dim LastMoveParType Dim CurParNum i = 1 If bMove = 1 Then Select Disk 1 Select Partition dLastOpPar CurParNum = GetPartitionNumber Next If IsPrimary Then LastMoveParType = 1 Else LastMoveParType = 0 End If Do While i < dOperPnum Select Partition Next If IsPrimary Then If LastMoveParType = 0 Then Select Disk 1 Select Partition Extended Resize Min End If Else If LastMoveParType = 1 Then Select Disk 1 Select Partition Extended Resize Left Boundary Max End If End If Select Partition CurParNum Move Left Max If IsPrimary Then LastMoveParType = 1 Else LastMoveParType = 0 End If CurParNum = GetPartitionNumber Next i = i + 1 Loop // Select the last unallocated space (the one just freed) Select Unallocated After Selected Partition // Create a partition of the specified size at the end of the hard drive, the volume label is SYS_GHOST, of course, you can modify the label according to the actual situation. Create /FS=FAT32 /LABEL="SYS_GHOST" // Convert this partition to a primary partition Convert To Primary End If // If bMove = 1 End If // If bMove = 0 End If // If bDone = 0 End If // If PriNum < 4 |
|
| Floor81 walu | Posted 2004-03-20 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Thanks, Brother Climbing! I waited for you all morning today, and finally got your help. I spent the whole morning and still couldn't figure it out. Well, I'm a computer illiterate and also an English illiterate.
This script passed the test just now completely. I have been testing in a virtual machine for PQMAGIC automatic lossless partition. In fact, if you use a loop, moving data on a real computer is very, very slow. Imagine, after moving the data of the last partition, you still need to move the second - last one, then the third - last one... So I think the loop in the V3 script is theoretically perfect, but in practice it will cause a dilemma: once you start partitioning, you can't exit. Either wait for an hour or several hours, or exiting will cause a partition table error (exiting is definitely not allowed). So I think that if you want to move partition data, you can only move one partition, not more than two. Otherwise, it's better to transfer the files of the partition to be moved to other partitions under WINDOWS first, and then operate. Therefore, I bother Brother Climbing again to make such a script: first check the last partition, if there is enough space, then operate; if not enough space, then check the first partition...; if not enough, then check the second partition (drive D). If there is space, intercept the required space from the front part of drive D (only the front part); if drive D is not enough space, then intercept the required space from the second - last logical partition and give it to the last partition, then free up space from the last partition and create the required primary partition. Brother Climbing, this is the last trouble for you on the automatic partition issue. I'm really sorry. I hope you can help. Thank you! Waiting for your good news. |
|
| Floor82 walu | Posted 2004-03-20 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
If there is still no space in the second-to-last logical partition, the automatic partitioning operation will be exited.
|
|
| Floor83 Climbing | Posted 2004-03-20 00:00 |
| 铂金会员 Posts 2,753 Credits 6,964 From 河北保定 | |
|
I went to take an exam in the morning and didn't have a chance to go online.
I think the script for V4 is basically the final version because since you ultimately need to create this partition, you'll have to wait this long sooner or later, and the V4 version has tried to consider various situations as much as possible. If we were to consider your situation, the script would become too complicated. It's better to directly use pqmagic to partition this partition manually. Don't you think so? After all, a program is a program and can't consider all situations. At critical moments, people still need to be involved. For example, you can first manually organize the target hard drive so that the last partition (or the first partition) has enough space, and then run the script to create the partition. After all, moving too many partitions may also cause data loss. It's best to back up the data before operating. |
|
| Floor84 walu | Posted 2004-03-20 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
Brother Climbing, can you tell me how to define the second-to-last partition? That is, how to express the second-to-last partition in the script? Thanks!
|
|
| Floor85 Climbing | Posted 2004-03-20 00:00 |
| 铂金会员 Posts 2,753 Credits 6,964 From 河北保定 | |
|
The partition that you mentioned as the second - last is actually an unknown in the actual situation, do you understand? Let me give an example: if there is only one partition on your hard disk, there is no second - last partition, and this is one of the situations. Another situation is that the last partition is a primary partition while the second - last partition is a logical drive. And it is also possible that the last partition is a logical drive while the second - last partition is a primary partition. And all these need to be taken into account in your program. You have considered the program too simply, and if the program is considered so simply, it will definitely often have faults during operation, and a program that often has faults is meaningless.
Let me put it in the simplest sense. Suppose there are definitely more than two partitions on your hard disk: Then: Select Partition Last is to select the last partition, and then run a command: Select Partition Previous is to select the partition before the one that was just selected, and isn't this the second - last partition? So to sum up, the following two statements are to select the second - last partition on the hard disk: Select Partition Last Select Partition Previous But when writing an actual script program, you need to fully consider all the situations I mentioned earlier, otherwise the program will have errors during operation or an outcome inconsistent with your expectations. |
|
| Floor86 walu | Posted 2004-03-22 00:00 |
| 高级用户 Posts 201 Credits 916 | |
|
I accidentally discovered that after replacing the PQPB.RTC in PQMAGIC 7.0 PRO with the same-named file in PQMAGIC 8.02, PQMAGIC 8.02 can also run script files with the CMD parameter. In fact, the program running is still PQMAGIC 8.02, but it shows PQMAGIC 7.0 PRO. I tried it, and it is not unstable. After replacement, typing PQMAGIC /? shows the CMD parameter. Because I don't understand programming and other related knowledge, so is there anything improper about this? Is it that adding something related to CMD in PQPB.RTC can make PQMAGIC 8.02 use scripts? I think PQMAGIC 8.02 originally supports scripts, but it is hidden.
|
|
| Floor87 Climbing | Posted 2004-03-22 00:00 |
| 铂金会员 Posts 2,753 Credits 6,964 From 河北保定 | |
| Floor88 moroko | Posted 2004-03-23 00:00 |
| 高级用户 Posts 198 Credits 919 | |
|
If I were, I would give up PQ because lossless partition is very slow. So slow that it makes people can't stand it. Even have the heart to commit suicide.
|
|
| Floor89 moroko | Posted 2004-03-23 00:00 |
| 高级用户 Posts 198 Credits 919 | |
|
I used ghost to back up an XP, which is about 1 GB or so. Then using a script to partition the hard drive took an absolutely unimaginable amount of time. I feel it's better to forget it. Find another way to solve this partitioning problem. Does that mean only PQ can do it?
|
|
| Floor90 Climbing | Posted 2004-03-23 00:00 |
| 铂金会员 Posts 2,753 Credits 6,964 From 河北保定 | |
The following is a quote from moroko on 2004-3-23 1:02:45: The fastest way is to wipe out all the data on the hard drive and then repartition it. If you think your data is useless, this is the fastest way. Otherwise, there is probably no better way. Also, I don't understand why you backed up the xp with ghost before partitioning? As long as your partition has no logical errors, there is no need to do this at all. Also, if you use PQ to partition, unless there is a large amount of data on your hard drive that needs to be moved, the speed should be very fast. |
|
| Prev 1 … 3 4 5 6 7 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |