aliatgb Posted November 22, 2011 Posted November 22, 2011 I am looking for some help scripting a diskpart script so that it does this after windows is already installed:1. Takes the current Disk 0 drive and shrinks the C drive to 50% of total volume2. Splits the remaining space between drive letters M and N equally.This has to be done via percentages because the local drives will be different densities.A similar script is found in these threads and is close to what I need:@echo offsetlocal enabledelayedexpansionecho list disk>%temp%\listdisk.dpdiskpart /s %temp%\listdisk.dp >%temp%\disklist.datif exist %temp%\mkdisks.dp del %temp%\mkdisks.dp>nulfor /f "tokens=1-4 delims= " %%a in ('find /v "###"^<%temp%\disklist.dat^|find " Disk "') do ( set size=%%d if !size! LSS 1024 set /a size=!size!*1024 set cdrv=18432 for /l %%s in (18432,-4096,4096) do if !cdrv! gtr !size! set cdrv=%%s echo select %%a %%b >>%temp%\mkdisks.dp echo create partition primary size=!cdrv! NOERR >>%temp%\mkdisks.dp echo assign letter c NOERR >>%temp%\mkdisks.dp echo active >>%temp%\mkdisks.dp set /a size=!size!-!cdrv! set /a ddrv=!size!/10 set /a ddrv=!ddrv!*8) if !ddrv! GTR 0 ( echo select %%a %%b >>%temp%\mkdisks.dp echo create partition primary size=!ddrv! NOERR >>%temp%\mkdisks.dp echo assign letter d NOERR >>%temp%\mkdisks.dp set /a edrv=!size!-!ddrv! if !edrv! GTR 0 ( echo select %%a %%b >>%temp%\mkdisks.dp echo create partition primary NOERR >>%temp%\mkdisks.dp echo assign letter e NOERR >>%temp%\mkdisks.dp) ) else ( echo select %%a %%b >>%temp%\mkdisks.dp echo create partition primary NOERR >>%temp%\mkdisks.dp echo assign letter d NOERR >>%temp%\mkdisks.dp))endlocaldiskpart /s %temp%\mkdisks.dp This code creates a diskpart script, called mkdisks.dp. First, a "C:" partition with a max of 18GB to a min of 4GB in 4GB increments, depending on the amount of hard disk space, is added to the diskpart script. The remaining space is split to 80% for the "D:" partition, and the remaining to the "E:" partition. Basically I need help modifying that meet my requirements. Any tips?
Tripredacus Posted November 22, 2011 Posted November 22, 2011 IDK that seems a little complicated. If you install the WMI package, you can do a WMI script that would grab the volume size. That's my only idea.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now