Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Using DISKPART in a script

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Newman57

Newman57
  • Member
  • 2 posts
  • Joined 10-September 07
Hoping someone can help me out.

I'm trying to install WindowsXP 64 bit unattended using WindowsPE and want to partition the HD with 1 partition with 30GB and the rest of the disk with the remaining space.
The trouble I'm having is that the computers vary in configuration. Some have a card reader which WindowsPE sees as a disk (or at least DISKPART does).
The disk number varies so I'd like to use a script which reads the first available online disk (some of the computers have 2 disks) and remove all existing partitions and create a 30GB partition and a second one with the remaining space.

Does anyone know how to do this?

Thanks in advance.


How to remove advertisement from MSFN

#2
hj_fr

hj_fr

    Member

  • Member
  • PipPip
  • 142 posts
  • Joined 09-August 04
yes easy:

Launch: diskpart /s diskpart.script
and in your diskpart.script something like:
select disk 0
clean
create partition primary size=30000
active
assign letter=c
create partition primary
assign letter=d
exit

Edited by hj_fr, 11 September 2007 - 01:33 AM.


#3
mallen

mallen

    Newbie

  • Member
  • 15 posts
  • Joined 16-September 04
I see where you're coming from - I had a similar problem when I wanted to use diskpart to change the drive letter of the CDROM drive. I couldn't guarantee which volume it would be. In the end I put together a short VBS script. Use a script to identify which drive it is you want to change. Remember you can use drive letters when specifying the volume in diskpart. With the same vbs script, write out a diskpart.txt script that is specific to that machine, then use the method mentioned above to call it.

Here is how I managed to get this working for a cdrom:

Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set CDRoms = FileSystemObject.Drives
Set wshShell = WScript.CreateObject ("WScript.shell")

Dim DVDDriveLetter

For Each CDDrive in CDRoms

If CDDrive.drivetype = "4" Then
DVDDriveLetter = CDDrive.driveletter
End If
Next


Set objTextStream = FileSystemObject.OpenTextFile("C:\diskpart.txt", 2, True)
objTextStream.WriteLine "SELECT VOLUME " & DVDDriveLetter
objTextStream.WriteLine "ASSIGN LETTER=Z"
objTextStream.WriteLine "EXIT"
objTextStream.Close

Set CDRoms = nothing
Set FileSystemObject = nothing
set wshshell = nothing


You could use a similar method to check for a file you know is on the disk you want to change.

Edited by mallen, 11 September 2007 - 01:51 AM.


#4
Newman57

Newman57
  • Member
  • 2 posts
  • Joined 10-September 07
Thanks mallen,

You've been most helpfull.

#5
mobious99

mobious99

    Newbie

  • Member
  • 25 posts
  • Joined 28-May 08
I do something for my vmware builds to make sure the alignment is correct

I found part of this online but added some of the stuff I was already doing to it.

The volume labels you can change this does up to 4 drives and changes the cdrom drive to z:

@echo off
rem Create and Format partition(s)
rem first assign the cdrom drive to z:

:CDROM
rem Create Diskpart Script
echo select disk 0 >"c:\source\scripts\part.txt"
echo select volume d >>"c:\source\scripts\part.txt"
echo assign letter Z noerr >>"c:\source\scripts\part.txt"

rem change cdrom drive letter Partition
DiskPart /s "c:\source\scripts\part.txt"

:DDRIVE
echo select disk 1 > "c:\source\scripts\part.txt"
echo create partition primary align=64 >>"c:\source\scripts\part.txt"
echo assign letter=D >>"c:\source\scripts\part.txt"
echo active >>"c:\source\scripts\part.txt"

rem Create Partition
DiskPart /s "c:\source\scripts\part.txt"
format D: /FS:NTFS /V:ddrive /q /A:32K /y

:EDRIVE
echo select disk 2 >"c:\source\scripts\part.txt"
echo create partition primary align=64 >>"c:\source\scripts\part.txt"
echo assign letter=E >>"c:\source\scripts\part.txt"
echo active >>"c:\source\scripts\part.txt"

Rem creating partition
DiskPart /s "c:\source\scripts\part.txt"

rem Format Partition
format E: /FS:NTFS /V:edrive /q /A:32K /y

:FDRIVE
echo select disk 3 >"c:\source\scripts\part.txt"
echo create partition primary align=64>>"c:\source\scripts\part.txt"
echo assign letter=F >>"c:\source\scripts\part.txt"
echo active >>"c:\source\scripts\part.txt"

rem Create Partition
DiskPart /s "c:\source\scripts\part.txt"

rem Format Partition
format F: /FS:NTFS /V:fdrive /q /A:32K /y

:Error
rem Return ACCESS DENIED
set ERRORLEVEL=5

:EXIT




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN