DISKPART scripting problem

cknoderer
cknoderer used Ask the Experts™
on
I am trying automate some commands using DISKPART. I am booting from a WinPE disk and running  DISKPART -s scriptname.s . When I run my script it selects the correct disk and cleans it and quits. I've tried various combinations to try and get it to run the entire process and it just quits after cleaning the disk.

I am trying to get DISKPART to clean the disk, create 2 partitions. 1 - 100mb NTFS primary  partition and 1 - NTFS primary paritition with remaining free space.

Could someone help me put together the correct script?  I'm not opposed to making the script a batch file either.  My script is listed below.

select disk 0
clean
CREATE PRIMARY PARTITION SIZE=100
CREATE PRIMARY PARTITION
SELECT PARTITION 1
FORMAT FS=NTFS QUICK
SELECT PARTITION 2
FORMAT FS=NTFS QUICK
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I created a logfile after running my script. It shows the same thing the screen does after I run the script.


Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: MININT-3RA94OJ

Disk 0 is now the selected disk.

DiskPart succeeded in cleaning the disk.

Microsoft DiskPart version 6.1.7601

PARTITION   - Create a partition.
VOLUME      - Create a volume.
VDISK       - Creates a virtual disk file.
I believe the error is in "CREAT PRIMARY PARTITION".

Try this:

SELECT DISK 0
CLEAN
CREATE PARTITION PRIMARY size = 100
SELECT PARTITION 1
FORMAT FS=NTFS QUICK
CREATE PARTITION EXTENDED
CREATE PARTITION LOGICAL
SELECT PARTITION 2
FORMAT FS=NTFS QUICK

Author

Commented:
Thanks dennisbbb. That was what i was looking for. It works! I finally got my script to work and was even able to add it to a batch file that I run on the WinPE disk. Below is what I ended up with.

I run DISKPART -S SCRIPTNAME.TXT  The script contains the following text:
SELECT DISK 0
CLEAN
CREATE PARTITION PRIMARY size = 100
SELECT PARTITION 1
FORMAT FS=NTFS QUICK
CREATE PARTITION PRIMARY
SELECT PARTITION 2
FORMAT FS=NTFS QUICK
ASSIGN LETTER=C
ACTIVE


I created a batch file that runs this script, addes the image to the C drive, runs the bcdboot command then reboots the computer. You can name the batch file anything you want.  My batch file contains the text below:
DISKPART -S F:\DISKPART.TXT
F:\IMAGEX /APPLY F:\IMAGES\OPTIPLEX380B.WIM 1 C:
BCDBOOT C:\WINDOWS /S C:
EXIT

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial