PartitionMagic Pro Scripting
PartitionMagic Pro Scripting
1
Using Script Processing
You can use PowerQuest® PartitionMagic® Pro scripts to make changes to the partitions
and volumes on a machine. A script is an ASCII text file with text statements that define
the operations you want to perform.You can create a script file with ScriptBuilder or with
any text editor.
5 Repeat steps 3 and 4 until you are finished creating the script.
6 To save your script file, click File {bmc 1Step.bmp} Save As, type a path and
filename for the file, then click OK.
The script text file allows comments in the C++ form (//). These can be either a full line or
after a valid statement.
Τo delete syntax, select the line you want to remove in the script edit pane, then press
<Delete>. You can also right-click in the script editing pane to cut, copy, paste, or delete
lines from the script.
When you are finished creating and saving the script file, you are ready to use the Play
command on the Script pull-down menu to compile the file. If the script has not yet been
saved, the Play command changes to Save and Play.
Use Check Syntax to test the entire syntax in the script for errors.
Any errors in the syntax are listed in the error pane directly below the script edit pane. You
can increase or decrease the viewing area of either pane by dragging the horizontal
separator bar up or down.
Recording Scripts
Instead of creating a script by selecting items from the Insert menu in ScriptBuilder, you
can “record” a script while you use PartitionMagic.
PowerQuest Corporation 3
When you select an option, the associated script command is sent to ScriptBuilder
and inserted into the script edit pane at the current cursor location.
3 When you are finished recording, click Tools ➤ Scripting ➤ Record to turn off
recording.
4 You may be prompted to discard any virtual changes you made to your machine while
recording the script. If so, click Yes to erase all changes, or click No to apply all
changes.
Regardless of whether you click Yes or No, your script will remain intact.
Playing Scripts
You can play a script from ScriptBuilder, PartitionMagic Pro, or the PartitionMagic Pro
command line.
PartitionMagic Click Tools ➤ Scripting ➤ Play Script File, specify the path and
Pro filename of the .PQS file you want to run, then click Play.
PartitionMagic Use the /CMD command line switch to run a script from the
Pro command command line without opening PartitionMagic. If the script file
line were named SCRIPT.TXT, the syntax for running the program from
the script would be:
PQMAGIC /CMD=SCRIPT.TXT
If the program encounters an error, the script will end immediately and an error will be
displayed in the message pane. You can also determine if an error has occurred and what
error it was by looking at the log file or error file. These two files are only created if you
specify them on the command line.
Sometimes the script cannot complete an operation because the disk configuration is not
correct for the script commands. If that is the case, it reports “0 operations pending” and
“script complete.” No error is reported.
Each operation in a script is performed on the partition that was last specified. You must
specify the correct partition before running a script.
Scripting Commands
You can use scripting commands to perform almost any operation that is available from
the Operations menu in PartitionMagic.
You insert a command into the script edit pane of ScriptBuilder by clicking Insert ➤
Command.
To add any optional or required parameters to a command that is inserted in the script edit
pane, click the line that you want to affect, click Insert ➤ Parameter, then select a
parameter. If you click Insert and the Parameter option is dimmed (unavailable), the
command does not have any parameters.
Allow the script to run even if it is determined that the program cannot reboot the machine
remotely, after changes are made. This should be the first statement if used.
No parameters.
Check
No parameters.
PowerQuest Corporation 5
You should use the check command in almost every script for each partition you will be
affecting. If any disk error exists, the check command will detect it and exit the script
before any problems occur.
Cluster Analyzer
Syntax
Cluster Analyzer [/SetClusterSize={ Recommended|512 | 1 | 2
| 4 | 8 | 16 | 32 | 64 }]
If this operation is used with out any parameters it will output a Cluster Analysis screen.
Parameter Description
/SetClusterSize Changes the cluster size to the specified size.
Convert To FAT
Convert a FAT32 or NTFS partition to FAT.
Convert To FAT32
Convert To HPFS
Convert to NTFS
Convert a FAT partition to NTFS. Under Windows® 2000, you can convert a FAT32
partition to a NTFS partition. If you use this command, you must be in Windows.
Convert To Primary
Convert To Logical
Syntax
Parameter Description
Copy a partition to unallocated space. For the Copy command to work correctly, a disk
and partition need to be selected and a destination disk and unallocated space need to be
selected.
Create
Syntax
Create /FS={FAT | FAT32 | HPFS | LINUXEXT2 | LINUXSWAP | NTFS
| EXTENDED | UNFORMATTED} [/Label="NEW LABEL"] [/Size=Value]
[/Position={BEGINNING | END}]
Parameter Description
/FS (Required) It can be any of the above specified strings. There may be
cases where creating with a certain /FS would fail. For example,
trying to create an Extended partition when one already existed.
PowerQuest Corporation 7
Parameter Description
/Label (Optional) Replace "NEW LABEL" with the desired volume label. It
must be 11 characters or less for FAT partitions.
Labels must be16 characters or less for Linux Ext2 partitions and 32
characters or less for NTFS partitions. The label must be in double
quotes. The script may fail if invalid characters are entered.
/Size (Optional) Specified in megabytes and will default to the size of the
unallocated space if not specified.
Delete
Syntax
Delete {Volume Name | "NO NAME" | "SWAPSPACE2" |"UNKNOWN"}[/Shred]
Parameter Description
Volume Name You must enter the volume name to ensure that you are destroying
data in the proper partition only. The value entered must always be
preceded and followed by double quotes. If the partition label is
blank and the partition is FAT or HPFS, enter “NO NAME.” If the
partition is not FAT or HPFS, enter “UNKNOWN.” To delete an
unformatted partition or an extended partition, enter “NO NAME.”
To delete a Linux swap partition, enter “SWAPSPACE2.”
/Shred (Optional) Permanently destroys both the data and the selected
partition. Undelete can not be used to reverse this command. This
command takes much longer than Delete.
The Shred parameter functions the same as the “Delete and Secure
Erase” operation found in PartitionMagic.
Delete All
Syntax
Format
Syntax
Format {Volume Name | "NO NAME" | "UNKNOWN" } /FS={ FAT |
FAT32 | HPFS | LINUXEXT2 | LINUXSWAP | NTFS } [/Label="NEW
LABEL"]
Parameter Description
Volume Name Required to format a partition UNLESS the partition is either an
extended partition or an unformatted partition. This is a check to
ensure that you are destroying data in the proper partition only. The
value entered must always be preceded and followed by double
quotes. If the partition label is blank and the partition is FAT or
HPFS, enter “NO NAME” as the label. If the partition is not FAT
or HPFS, enter "UNKNOWN" as the label.
/FS (Required) Can be any of the above specified strings. There may be
cases where formatting with a certain /FS would fail, for example
trying to format a FAT partition past 1024 cylinders.
/Label (Optional) Replace "NEW LABEL" with the desired volume label.
It must be 11 characters or less for FAT partitions. Labels must
be16 characters or less for Linux Ext2 partitions and 32 characters
or less for NTFS partitions. The label must be in double quotes.
The script may fail if invalid characters are entered.
Hide
Info
Syntax
Info [/Usage ] [/Waste ] [/Partition ] [/FS]
PowerQuest Corporation 9
Use to get information about a selected partition. All parameters are optional. When no
parameters are supplied, the default is to show information for all that apply.
Parameter Description
/Usage The Disk Usage screen is available for the FAT, FAT32, NTFS, and
HPFS file systems.
The next section of the screen shows physical information about the
partition, including the following:
• First Physical Sector shows the logical number and the location
(cylinder, head, and sector) where the partition begins.
• Last Physical Sector shows the logical number and the location
(cylinder, head, and sector) where the partition ends.
• Total Physical Sectors gives the number of sectors in the
partition.
• Physical Geometry shows the number of cylinders, heads, and
sectors of the physical disk drive on which the partition resides.
PowerQuest Corporation 11
Parameter Description
/FS For FAT partitions, this parameter displays a screen with the
following information. The first section on this page provides the
(FAT or following information about the file system:
FAT32)
• Sectors per FAT
• Root directory capacity
• First FAT sector
• First Data sector
Several extensions to the FAT file system exist. The final section of
this page gives the following information about FAT extensions:
• Number of byes used for OS/2 Extended Attributes and how
many files and directories the Extended Attributes are associated
with Number of byes used for long file names and the number of
files and directories the long file names are associated with
/FS For NTFS partitions, this parameter displays a screen with the
following information. This screen shows the following file system
(NTFS) information for the selected partition:
• NTFS Version shows the version number.
• Bytes per NTFS sector displays the number of bytes in each
logical sector on the selected partition. (There are always 512
bytes in each physical sector.)
• Cluster size
• First MFT Cluster
• File Record Size
/FS The next section shows information similar to that shown by NTFS
CHKDSK, including the following:
(NTFS
continued) • Number of files and the byes and clusters allocated to them
• Of the clusters used in files, the number of wasted bytes
resulting from the cluster size
• Number in indexes (directories) and the space allocated to them,
shown in bytes and clusters
Space reserved for other system structures, shown in both bytes and
clusters
/FS For HPFS partitions, this parameter displays a screen with the
following information. The first section on this page provides the
(HPFS) following information about the file system:
• Partition status (that is, is partition active?)
• DirBlock sectors
• Free DirBlocks
• Hot Fixes Used
Label
Syntax
Label [/GetLabel ] [/SetLabel="NAME"]
The default with no parameter is GetLabel, which reports the label of the seleted partition.
PowerQuest Corporation 13
The /SetLabel option lets you change the name of a selected partition. Labels can be up to
11 characters for FAT, FAT32, and HPFS partitions, 32 characters for NTFS partitions, and
16 characters for Linux Ext2 partitions. Labels for FAT, FAT32, or HPFS partition types
follow the same rules as DOS names, with two exceptions: spaces are allowed, and no
period is required between the first eight characters and the last three.
Merge
Syntax
Merge /Target={First | Second} /Folder=”NAME” [/FS={FAT |
FAT32 |NTFS]
Use Merge to join two FAT or FAT32 partitions that are adjacent (unallocated space can
exist between them, however) to each other on a hard disk. This is useful if you have
reached the maximum number of partitions on your disk, but you do not want to delete a
partition.
You can also use Merge to join two adjacent NTFS partitions with the same cluster size
and version type. To ensure that two NTFS partitions have the same cluster size and
version type, right-click a partition in the partition map, then select Info from the menu.
Click the NTFS Info tab, and view the cluster size and version type.
For the Merge command to work correctly, two adjacent FAT or FAT32 partitions, or two
NTFS partitions with the same cluster size and version type must be selected. You should
not merge any partitions that include an operating system.
Parameter Description
/Target Specifies which partition you want to keep. For example, if you choose
First, the second partition you selected will merge into the first partition
you selected.
/Folder Specifies the folder name for the data that is merged into the target
partition. For example, if you had a DATA partition and a BACKUP
partition and you were keeping the DATA partition, you could specify
“BACKUP” as the folder name. After the merge, all the data from your
BACKUP partition would be in a BACKUP folder inside the DATA
partition.
/FS= FAT | (Optional) You can specify the resulting file system. If you do not use
FAT32 | this parameter, PartitionMagic Pro will choose the best file system
NTFS automatically.
Move Left
Syntax
Move Left {Max | Min | Value }
Parameter Description
Max Move the partition as far to the left as possible. Flush with the previous
partition or beginning of the drive.
Min Move the partition to the left, the minimum amount possible (1
cylinder).
Value Move the partition left by the amount of the value specified (in
megabytes).
Move Right
Syntax
Move Right {Max | Min | Value }
Parameter Description
Max Move the partition as far to the right as possible. Flush with the next
partition or end of the drive.
PowerQuest Corporation 15
Parameter Description
Min Move the partition to the right the minimum amount possible (1
cylinder).
Value Move the partition right by the amount of the value specified (in
megabytes).
Syntax
Move Space After {Max | Value }
Parameter Description
Max Same as Move Left Max. Makes as much space after the partition as
possible by moving the partition left.
Value Moves the partition left or right such that the space after is equal to
the value specified if possible (specified in megabytes).
Syntax
Move Space Before {Max | Value }
Parameter Description
Max Same as Move Right Max. Makes as much space before the partition
as possible by moving the partition right.
Value Moves the partition right such that the space before is equal to the
value specified if possible (specified in megabytes).
Resize
Syntax
Resize a partition.
Parameter Description
Max Resizes to the maximum size possible. The right edge of the
partition will be flush with end of drive or next partition, if possible.
/SetClusterSize Will set the cluster size to the size specified during the resize
operation. The cluster size must be valid for the partition size
specified.
Resize Larger
Syntax
Resize Larger {Max | Min | Value} [/SetClusterSize={512 | 1
| 2 | 4 | 8 | 16 | 32 | 64}]
Resize a partition larger by specifying the incremental change in size. See also, “Resize.”
Parameter Description
Value Grows the size of the partition by the size specified (in megabytes).
/SetClusterSize Sets the cluster size to the size specified during the resize operation.
(The cluster size must be valid for the partition size specified.)
Syntax
Resize Left Boundary {Max | Min | Value }
PowerQuest Corporation 17
Resize the extended partition by moving the left boundary. This operation is for
extended partitions only. .
Parameter Description
Max Resizes to the maximum size possible. The left edge of the partition
will be flush with the left end of drive or previous partition, if
possible.
Min Resizes to the minimum possible (determined by the size of the data).
Syntax
Resize Left Boundary Larger {Max | Min | Value }
Resize an extended partition larger by specifying the change in position of the left
boundary. This operation is for extended partitions only.
Parameter Description
Max Same as Resize Left Boundary Max. Make the partition as large as
possible.
Min Increase the size of the partition by the smallest amount possible (1
cylinder).
Value Increase the size of the partition by the size specified (in megabytes).
Syntax
Resize Left Boundary Smaller {Max | Min | Value }
Parameter Description
Max Same as Resize Left Boundary Min. Make the partition as small as
possible.
Resize Smaller
Syntax
Resize Smaller {Max | Min | Value} [/SetClusterSize={512 |
1 | 2 | 4 | 8 | 16 | 32 | 64 }]
Resize a partition smaller by specifying the incremental change in size. See also, "Resize."
Parameter Description
/SetClusterSize Sets the cluster size to the size specified during the resize operation.
The cluster size must be valid for the partition size specified.
Syntax
Resize Space After {Max | Min | Value}
[/SetClusterSize={512 | 1 | 2 | 4 | 8 | 16 | 32 | 64 }]
PowerQuest Corporation 19
Resize a partition by specifying the unallocated space desired after the partition after the
resize is completed. This operation is for all partitions, including extended partitions. See
also, "Resize."
Parameter Description
Max Resizes so that the space after the partition is as large as possible.
The partition is as small as possible.
Min Resizes so that the space after the partition is as small as possible.
The partition is as large as possible.
Value Sizes the partition such that the space after is the size of value (in
megabytes).
/SetClusterSize Sets the cluster size to the size specified during the resize operation.
Cluster size must be valid for the partition size specified.
Syntax
Resize Space Before {Max | Min | Value }
Resize an extended partition by specifying the unallocated space desired before the
partition after the resize is completed. This operation is for extended partitions only.
Parameter Description
Max Resizes so that the space before the partition is as large as possible.
The partition is as small as possible.
Min Resizes so that the space before the partition is as small as possible.
The partition is as large as possible.
Value Sizes the partition such that the space before is the size of value (in
megabytes).
Resize Root
Syntax
Resize Root {Value | Min | Max }
Parameter Description
Value Must be a value between 512 - 1024. This will change the maximum
number of root entries possible for this partition. The number
actually set will be the closest number possible to the number
specified.
Min Sets the partition to having the smallest possible maximum number
of root entries.
Max Sets the maximum number of root entries for the partition to the
largest number possible.
Select
You do not need to select a disk when selecting a partition by letter or volume. All the
disks are searched in order until the specified letter or volume name is encountered. This
means that if two partitions have the same volume name, the first partition found is the one
that is selected.
The Next and Previous commands are relative to a previous selection of the same type.
You must already have a partition selected before using Select Partition Next or Select
Partition Previous. Likewise, you must have an unallocated space selected before using
Select Unallocated Next or Select Unallocated Previous.
Select Disk
Syntax
Select Disk {Number}
Select Partition
Syntax
Select Partition [{Number} | {Letter} | {"Volume"} | First |
Last | Next | Previous | Extended}]
Select a partition. If you select a partition by letter, you must type the letter in uppercase.
PowerQuest Corporation 21
There are no parameters.
Select Unallocated
Syntax
Select Unallocated [{Number} | First | Last | Largest | Next
| Previous | After Selected Partition | Before Selected
Partition}]
Syntax
Select Merge Partition {Next | Previous}
Select a partition to merge with an adjacent partition. This command must be preceded by
a Select Partition command.
Select the destination hard disk. This command is used with the Copy command.
Syntax
Select Destination Unallocated | {{Number} | First | Last |
Largest | After Partition {Number} | Before Partition
{Number} | Next | Previous}
Select the destination unallocated space on the partition. This command is used with the
Copy command.
Set Active
Syntax
Set allow user cancel OFF to prevent interrupting a script that is running. This command is
turned on by default. If the cancel button is grayed out, then it is turned off.
Use this command when you play a script and you do not want the script to be interrupted
while it is running. Interrupting a playing script could potentially damage your hard drive.
Set the bad sector testing ON or OFF for all partitions on the currently selected drive. The
"/BadSectorTest" option overrides this setting.
Set the read-only flag ON or OFF for all partitions on the currently selected drive. When
set on for a drive, modifications to the partitions on that drive will not be allowed. Some
changes to boot.ini files may be allowed if they exist on the read-only drive when add,
delete or copy partition operations are done.
If you do not have OS/2 on your system, you can turn this option ON to ignore OS/2
Extended Attribute errors when it checks a FAT partition.
If this option is set ON, you can create FAT partitions with 64 K clusters, which allows
you to use PartitionMagic Pro to create FAT partitions up to 4 GB.
You should only use 64 K clusters with Windows NT or Windows 2000. If you use other
operating systems, you should not use 64 K clusters.
Set user logoff to on or off. When set to on, it will force all users to log off the system just
before the remainder of the script is played.
PowerQuest Corporation 23
Show
Syntax
Parameter Description
Partition Displays information about partitions. You must select the disk.
Destination Displays information about the destination disk. The command must
be preceded by Select Destination Disk command.
Unhide
Variables
Create a variable with a name you specify to assign a value for later use in conditional or
mathematical expressions.
Syntax
Dim {Put_variable_name_here}
For example, the following lines create a variable named “Number” and assign it the value
of 2.
Dim Number
Number = 2
Syntax
If {Put_condition_here} Then
// Put commands here
Else If {Put_condition_here} Then
// Put commands here
Else
// Put commands here
End If
Do...Loop While
Perform repeated statements until the condition is false or zero. The statements between
the Do and the Loop While {} commands are always played once before the condition is
tested.
Syntax
Do
// Put commands here
Loop While {Put_condition_here}
Do While...Loop
Perform repeated statements until the condition is false or zero. The statements between
the Do While {} and the Loop commands are never played if the condition is false or zero
the first time it is tested.
Syntax
Do While {Put_condition_here}
// Put commands here
Loop
PowerQuest Corporation 25
Exit Loop
Use the Exit Loop command to jump out of a Do...Loop While or a Do While...Loop
statement before reaching the end of the loop.
At least one command must exist after the loop or the script will stop with an error.
Operators
PartitionMagic supports the following operators in scripts.
Operator Action
Conditional
< Returns true if the left operand is less than the right operand.
> Returns true if the left operand is greater than the right operand.
<= Returns true if the left operand is less than or equal to the right
operand.
>= or => Returns true if the left operand is greater than or equal to the right
operand.
Mathematical
Assignment
= Assigns the value of the right operand to the left operand. For
example, X=3 means that X is set to the value of 3. You can also use
the operator inside parameters.
Operator Examples
Queries
To insert a query in a script using ScriptBuilder, click Insert ➤ Query. Queries are
inserted into the script edit pane at the location of your cursor and replace any selected
text.
PowerQuest Corporation 27
You can assign values returned from queries to variables or you can use them in
conditional or mathematical expressions. The following table shows the queries that are
available for your use.
Syntax: GetTotalDisks
Number of Partitions Gets the total number of partitions on the selected disk.
Syntax: GetTotalPartitions
Syntax: GetTotalUnallocatedSpaces
Disk Size Get the size of the currently selected disk, in megabytes.
Syntax: GetDiskSize
Disk Allocated {Size Get the size of disk allocated to partitions, in megabytes or as a
| Percentage} percentage.
Syntax: GetAllocatedSize
GetAllocatedPercent
Disk Unallocated Get the size of remaining unallocated space on the currently
{Size | Percentage} selected disk, in megabytes or as a percentage.
Syntax: GetUnallocatedSize
GetUnallocatedPercent
Syntax: GetSelectedPartitionSize
Partition Number Get the partition number of the selected partition. You can then
use the returned value with the Select Partition {Number}
command. A return of "0" indicates that the partition does not
exist. (For example, the GetPartitionNumber Extended
command returns "0" if there is no extended partition.)
Syntax: GetUsedAmount
GetUsedPercent
Syntax: GetUnusedAmount
GetUnusedPercent
Type Determine if the file system of the current partition is the type
specified.
Syntax:{IsActive | IsHidden}
Syntax:{IsPrimary | IsLogical}
Unallocated Size Get the size of the unallocated space, in megabytes.
Syntax: GetSelectedUnallocatedSize
PowerQuest Corporation 29
Query Use and Syntax
Unallocated Number Get the space number of the specified unallocated space. You
can then use the returned value with the Select Partition
{Number} command. A return of 0 (zero) indicates that the
unallocated space does not exist. (For example, the
GetUnallocatedNumber Next command returns 0 if there are
no unallocated spaces following the last selection.)
Examples
For example, in the following code, the variable dNumParts is defined, then assigned the
total number of partitions on disk 1.
Dim dNumParts
Select Disk 1
dNumParts = GetTotalPartitions
In the following example, the largest unallocated space on disk 1 is selected. If it is larger
than 1000 MB, PartitionMagic Pro creates two partitions, each using approximately half
of the unallocated space.
Select Disk 1
Select Unallocated Largest
If GetSelectedUnallocatedSize > 1000 Then
Create /FS=FAT /Size = GetSelectedUnallocatedSize / 2
Select Unallocated After Selected Partition
Create /FS=FAT
End If
Partitions must start on cylinder boundaries. For example, if you specify 10 MB, the real
value could be10.2 MB. The difference between the specified and actual values varies
depending on the geometry of the drive.
When specifying an amount for one of the script options, the program will allow a margin
of error of 1 cylinder above or below that amount (or a range of 2 cylinders centered on the
amount specified). For example, if 10 MB were specified for a resize and a cylinder was .5
MB, that the operation would complete successfully if it could resize the partition to at
least 9.5 MB. The actual range would be 9.5 to 10.5 MB. If it could not resize the partition
within this range, it will return an error.
Under normal operation, if the script determines that it will not be able to reboot the
machine after making the changes specified in the script, the script will terminate with an
error. This condition will occur under OS/2 if the DOS.SYS file is not in the
CONFIG.SYS (such as when you boot from the utility disks). You should include
ALLOW MANUAL REBOOT as the first script statement in the script if performing a
manual reboot from the keyboard is not a problem.
All commands must be contained within one line. They cannot start on one line and finish
on the next. The maximum length of a script line is 180 characters, which should be
sufficient for any command.
Use extreme caution when selecting a partition by its number. The select by number
feature must be available to select unallocated space or partitions that have no drive letter
or label. The problem with selecting a partition by number is that the numbers can change
throughout a script. If you select partition 2 and move it to the right, any unallocated space
that has been moved from the right to the left side of the partition will now become
partition 2. (The partition moved will still be selected regardless of the number). Using the
Select Unallocated After Selected Partition and Select Unallocated Before Selected
Partition commands is usually preferable to selecting unallocated space by partition
number. With most operations, the partition selected after an operation will be the partition
operated on. For example, Resize and Move will always leave the partition operated on as
the selected partition after the operation. On a Create command, the partition created will
be selected after the command whether it is at the beginning or end of the unallocated
space it was created in. If there is any doubt as to which partition will be selected after an
operation, you can use the DOS (rescue disk) version of the program (without scripting)
PowerQuest Corporation 31
and perform the same operation on a test machine and observe which partition is selected
after the operation. You can also use the Show Partitions command to show the current
status of partitions.
Sample Scripts
Scenario 1: General Example
You have primary C:, D:, and E: drives. There is no unallocated space on the disk. You
want to take 10 MB from D: and add it to E:.
SCRIPT1.PQS
//Check the partitions to be operated on first
Select Partition D
Check
Select Partition E
Check
//Select the first partition I want to change
Select Partition D
//Shrink the partition by 10 megabytes
Resize Smaller 10
//Select the partition to add the 10 meg to
Select Partition E
//Move the partition as far as possible to the left so that
//the unallocated space just created will be on the right
//edge (the end)
Move Left Max
//Take up all of the available space
Resize Larger Max
You have one large C: partition on the drive. The drive is 1.2 GB in size. You have only
300 MB of data on the partition and would like to create logical drives D: and E:. The E:
drive needs to be 300 MB, and the rest of the disk space is to be split between the C: and
D: drives.
SCRIPT2.PQS
The C: partition is a primary partition, and the D: and E: partitions are logical drives in an
extended partition. You want to create an F: partition with 40 MB of unused space that is
in the C: partition. The F: partition will be a FAT partition with a volume label of “DATA,”
Since the drive is fairly new, you would like to skip bad sector testing for all operations.
PowerQuest Corporation 33
SCRIPT3.PQS
//Check all of the partitions first
Select Partition C
Check
Select Partition D
Check
Select Partition E
Check
//Since a partition on this drive had already been selected,
//we can set the default bad sector testing to off for this
//drive
Set Default Bad Sector Test State Off
//Select the C partition and shrink it by 40 MB
Select Partition C
Resize Smaller 40
//Select the extended partition and resize the left
//boundary to the right edge of the C partition (max),
//putting the unallocated space within the extended
//partition. To select an extended partition, the drive must
//first be selected, and then the partition.
Select Disk 1
Select Partition Extended
Resize Left Boundary Max
//Select the D partition and move it to the left, essentially
// flush against the Extended and C partitions, leaving the
// unallocated space between the D and E partitions
Select Partition D
Move Left Max
//Select the E partition and move it as far as possible to
//the left, so that the unallocated space will be at the end
//of E, within the extended partition
Select Partition E
Move Left Max
//The unallocated space is now after E and the user
// can create an F partition (logical drive)
The user has a C partition which is a primary having 100 MB. The next partition is a
hidden partition called NT_OS which is FAT and a primary partition at 100 MB. There are
also 2 logical drives, D and E in an extended partition which are each 70 MB.
The user wants to reduce both the C and Hidden partitions to 60 MB, add 40 MB to the D
partition, and create an F partition (NTFS) with the remaining unallocated space. The user
also wants to convert the hidden partition from FAT to NTFS. The user also does not care
whether the machine can reboot under program control or not.
SCRIPT4.PQS
//Inform that a manual boot is acceptable
Allow Manual Reboot
//Check all of the partitions first
Select Partition C
Check
//The hidden partition is selected by using the volume label
//in quotes
Select Partition "NT_OS"
Check
Select Partition D
Check
Select Partition E
Check
//Select the C Partition and resize it to 60 MB
Select Partition C
Resize 60
//Select the hidden partition
Select Partition "NT_OS"
PowerQuest Corporation 35
//Move the partition flush against the C partition (since it
//was just resized) putting the newly created unallocated
//space after the hidden partition
Move Left Max
//Resize the hidden partition to 60 MB
Resize 60
//Convert the partition from FAT to NTFS
Convert To NTFS
//Expand the extended partition so that the unallocated
//space is now inside the expanded partition
Select Disk 1
Select Partition Extended
Resize Left Boundary Max
//Move the D partition flush against the hidden and extended
//partitions
Select Partition D
Move Left Max
//Add 40 MB to the D partition
Resize Larger 40
//Move the E partition next to the D partition
Select Partition E
Move Left Max
//The unallocated space is now available at the end of the
//extended partition so that you can create an F logical
//drive. Select the unallocated space.
Select Unallocated After Selected Partition
//Create the NTFS partition.
Create /FS=NTFS
Imagine you have a 3.2 GB drive. You have a 2 MB primary partition and a 1 GB primary
FAT C: partition. You also have a hidden primary FAT partition that is 1 GB. You boot
multiple operating systems, and the third partition holds another operating system. You
also have an extended partition with logical drives that use up the rest of the drive space.
SCRIPT5A.PQS
// Show Cluster Waste for Partition 2
Select Disk 1
Select Partition 2
Cluster Analyzer /ShowClusterWaste
// Show Cluster Waste for Partition 3
Select Disk 1
Select Partition 3
Cluster Analyzer /ShowClusterWaste
You can now know you can reduce cluster waste, so you use the Cluster Analyzer to
reduce waste again. You will set the third partition to the recommended size and the
second partition to a cluster size of 8K.
SCRIPT5B.PQS
// Set Partition 3 to Recommended Cluster Size
Select Disk 1
Select Partition 3
Cluster Analyzer /SetToRecommended
// Set Partition 2 to 8K Clusters
Select Disk 1
Select Partition 2
Cluster Analyzer /ClusterSize=8
Scenario 6: Copy
You just installed a new drive. You would like to copy the first three partitions on drive 1
to drive 2. Drive 2 is formatted and is unused space.
SCRIPT6.PQS
// Select Disk 1, then select and check partitions 3, 2, and
//1.
Select Disk 1
Select Partition 3
Check
PowerQuest Corporation 37
Select Partition 2
Check
Select Partition 1
Check
// Select Destination Disk 2, Copy Partition 1
Select Destination Disk 2
Select Destination Unallocated First
// Copy First Partition
Copy
// Select Disk 1, Partition 2
Select Disk 1
Select Partition 2
// Select Destination Disk 2, Copy Partition 2
Select Destination Unallocated First
// Copy Second Partition
Copy
// Select Disk 1, Partition 3
Select Disk 1
Select Partition 3
// Select Destination Disk 2, Copy Partition 3
Select Destination Unallocated First
// Copy Third Partition
Copy
Scenario 7: Info
You have a FAT C: partition that you would like to get some information about.
You do not know how big the partition is or much about it. You would like to know about
the disk usage, the cluster waste, partition information, and file system information.
SCRIPT7A.PQS
Select Disk 1
Select Partition 1
Info /Usage /Waste /Partition /FS
SCRIPT7B.PQS
Select Disk 1
Select Partition 1
Info /Usage
Info /Waste
Info /Partition
Info /FS
SCRIPT8.PQS
// Select the last partition
Select Disk 1
Select Partition Last
// Loop thru the logical partitions and remove 10 MB of
//unused space (if available).
Do While IsLogical
If GetUnusedAmount > 10 Then
Resize Smaller 10
Move Right Max
End If
Select Partition Previous
Loop
// Resize the extended partition to fit the logical
// partitions
Select Partition Extended
Resize Left Boundary Min
// Expand the primary partition to include the unused space
Select Partition Previous
Resize Larger Max
PowerQuest Corporation 39