[quote=“astrouga, post: 8537, member: 907”]Since I use “one image to rule them all”, I have to remember to shrink my partition down below the smallest disk in inventory before I sysprep it. Otherwise the image will fail on some systems. I have some disks that are 80GB and some that are 500GB. So I usually manually shrink my disk down below 80GB before I sysprep it. Then after imaging a system with larger disks, I have to extend the partition to the max size. I got tired of doing this manually, so I wrote a vbscript to do this for me. I’m sharing it in hopes that it helps others, but also to see if anyone has a better way.
I actually use this snippet of code in a larger vbscript that does other things (local account creation, firewall exceptions, registry changes, printer installs, etc), but I’ve pulled out necessary the code below. Should be complete. Note it is actually two files. One is the vbscript that just runs diskpart, the other is a text file that contains the options to pass to diskpart.
[B][U]extend_max.vbs[/U][/B]:
[CODE]’ ########## Extend Disk Partition (MAX) ##########
LogFilename = “C:\Windows\Setup\InstallLog.txt”
LogFile.writeline “-------------------------------”
LogFile.writeline “Extending partition to max size:”
LogFile.writeline “-------------------------------” & VbCrlf
diskpartScript = “C:\Windows\Setup\Scripts\extend_max.txt”
Set oShell = CreateObject(“Wscript.Shell”)
Set oShellExec = oShell.Exec("cmd /c diskpart -s " & diskpartScript)
set oStdOutputText = oShellExec.StdOut
Do While Not oStdOutputText.AtEndOfStream
diskpartOutput = oStdOutputText.ReadLine
LogFile.writeline diskpartOutput
Loop[/CODE]
[B][U]extend_max.txt[/U][/B]:
[CODE]select disk 0
detail disk
list disk
select volume c
extend disk 0
list disk
exit[/CODE]
I call this script by adding a line to my SetupComplete.vbs script. Something like:
REG ADD %KEY%\005 /VE /D “Extending disk partition size to max” /f
REG ADD %KEY%\005 /V 1 /D “%systemroot%\Setup\Scripts\extend_max.vbs” /f
astrouga[/quote]
I modified my image to include this and it seems work on those pesky advance format drives