Avatar of cknoderer
cknoderer

asked on 

DISKPART scripting problem

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
PCPowershellMicrosoft DOS

Avatar of undefined
Last Comment
cknoderer
Avatar of cknoderer
cknoderer

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of dennisbbb
dennisbbb

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of cknoderer
cknoderer

ASKER

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
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo