Virtualization Technology News and Information
Article
RSS
MSVS 2005 - Converting Disk Types Programmatically
We've all been there.  You created a virtual machine disk file as either fixed or dynamic, only to realize later that you needed to have the opposite disk type.  Ben Armstrong comes to the rescue with a VBScript to do just that, programmatically change one disk type to another. 

set vsApp = CreateObject("VirtualServer.Application","localhost")

TargetVHDpath =Inputbox("Enter path and name of VHD to convert:")
FixedVHDpath =Inputbox("Enter path and name of VHD to create")

set target = vsApp.GetHardDisk(TargetVHDpath)

set convertTask = target.convert(FixedVHDpath,1)

while not convertTask.isComplete
     wscript.echo "Conversion is " & convertTask.PercentCompleted & "% complete"
     WScript.Sleep 2000
wend

wscript.echo
wscript.echo "Conversion complete"

NOTE:
  • Use CSCRIPT.EXE to run the script, and
  • The script converts a dynamic disk to a fixed disk. To do the opposite, change the "1" to "0" in the .convert() call.


To comment or thank Ben, visit his original post on his site, here.
Published Sunday, April 02, 2006 1:10 PM by David Marshall
Filed under:
Comments
There are no comments for this post.
To post a comment, you must be a registered user. Registration is free and easy! Sign up now!
Calendar
<April 2006>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456