MSFN Forum: Scripting Diskpart, multiple partition - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Scripting Diskpart, multiple partition Rate Topic: -----

#1 User is offline   xponard 

  • Group: Members
  • Posts: 7
  • Joined: 14-November 04

  Posted 04 January 2008 - 09:05 AM

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

This post has been edited by xponard: 04 January 2008 - 09:07 AM



#2 User is offline   hj_fr 

  • Member
  • PipPip
  • Group: Members
  • Posts: 140
  • Joined: 09-August 04

Posted 06 January 2008 - 12:25 PM

I don't know if you can calculate freespace
You must alwsay specify the size.

#3 User is offline   xponard 

  • Group: Members
  • Posts: 7
  • Joined: 14-November 04

  Posted 07 January 2008 - 03:37 AM

ok, I have found a solution based on the Scr1ptW1zard's answer : http://www.msfn.org/...on-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.

Attached File(s)


This post has been edited by xponard: 07 January 2008 - 04:28 AM


#4 User is offline   DonDamm 

  • Member
  • PipPip
  • Group: Members
  • Posts: 285
  • Joined: 24-May 05

Posted 07 January 2008 - 08:23 AM

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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy