Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using DISKPART in a script

Featured Replies

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.

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

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

  • 4 years later...

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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.