to use just a single cmd to perform the diskpart funtions; try somthing like... @echo off ver set script=%temp%\vdisk.txt >"%script%" echo create vdisk file=c:\Win7_x86.vhd maximum=%1 >>"%script%" echo select vdisk file=c:\Win7_x86.vhd >>"%script%" echo attach vdisk >>"%script%" echo exit diskpart /s "%script%" info on above: cmd is part of my windows 7 vhd based setup script placed in the pe system32 dir.