Jump to content

Scripting Diskpart, multiple partition


xponard

Recommended Posts

Hello there,

I am working with WinPE 2.0 and ImageX over USB Flash Disk trying to deploy HII XP SP2 image over multiple different computers.

I want to use a script that perform disk partition/format (using diskpart.exe /s myscript.txt) before deploying the image (imagex.exe /apply ...)

I need 3 partitions in this exact order :

C: [sYSTEM] 12Go

D: [DATA] all_of_free_space

Z: [MSI] 6Go

I juste want to know how to script this need.?

How to calculate automaticaly the all_of_free_space that is = Total Capacity - (12Go+6Go)

A simple way might be to create the partitions in this order: C(12)/Z(6)/D(no parameter, so all the free space) but I really would like to get the C/D/Z order...

Thanks in advance

:hello:

XP

Edited by xponard
Link to comment
Share on other sites


ok, I have found a solution based on the Scr1ptW1zard's answer : http://www.msfn.org/board/Diskpart-question-t108302.html

> :thumbup

@echo off
REM =====================================
REM Script de partitionnement du disque 0
REM Utilisation sous WinPE2.0/ImageX
REM C[12Go]/D[Total-(12+6)]/Z[6Go]
REM XP - 01/08
REM =====================================

setlocal enabledelayedexpansion
echo list disk>%temp%\listdisk.dp

diskpart /s %temp%\listdisk.dp >%temp%\disklist.dat

if exist %temp%\mkdisks.dp del %temp%\mkdisks.dp>nul
for /f "tokens=1-4 delims= " %%a in ('find /v "###"^<%temp%\disklist.dat^|find " Disk "') do (
If %%b EQU 0 (
set size=%%d
if !size! LSS 1024 set /a size=!size!*1024
set /a ddrv=!size!-18432

echo select disk 0 >>%temp%\mkdisks.dp
echo clean >>%temp%\mkdisks.dp
echo create part pri size=12288 >>%temp%\mkdisks.dp
echo select part 1 >>%temp%\mkdisks.dp
echo active >>%temp%\mkdisks.dp
echo assign letter=c: >>%temp%\mkdisks.dp
echo format fs=ntfs label="SYSTEM" quick >>%temp%\mkdisks.dp
echo create part pri size=!ddrv! >>%temp%\mkdisks.dp
echo select part 2 >>%temp%\mkdisks.dp
echo assign letter=d: >>%temp%\mkdisks.dp
echo format fs=ntfs label="DATA" quick >>%temp%\mkdisks.dp
echo create part pri size=6144 >>%temp%\mkdisks.dp
echo select part 3 >>%temp%\mkdisks.dp
echo assign letter=z: >>%temp%\mkdisks.dp
echo format fs=ntfs label="MSI" quick >>%temp%\mkdisks.dp
))
endlocal
diskpart /s %temp%\mkdisks.dp

Greetings.

XP.

diskpart_dynamique_valid_xp.cmd

Edited by xponard
Link to comment
Share on other sites

Nicely done. I was going to suggest that you have the script calculate remaining space and then subtract the 6GB from it and use the result as the second or D parameter. You beat me to it! :^) Note that the formatting is the Quick mode and good for most situations. If you want to do a full format for some reason, you'd need to change the script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...