Virtualization Technology News and Information
Article
RSS
VBScript to merge a differencing disk to a new file

For those of you using Microsoft Virtual Server, you might want to check this one out.  Here is a code sample from Ben Armstrong, the Virtual PC Guy, off of his Blog site to help you write your own VBScript to merge a differencing disk to a new file. 

As you can see, this script take two command line parameters: the differencing disk and the target disk.  It then merges the differencing disk with its parent and stores the result in the new target disk.

   1: Option Explicit
   2:
   3: 'Define constants
   4: CONST vmDiskType_Dynamic = 0
   5: CONST vmDiskType_FixedSize = 1
   6: CONST vmDiskType_Differencing = 2
   7:
   8: dim vs, aVHD, aVHDFileName, newVHDFileName, vmTask
   9:
  10: 'Grab command line arguments
  11: aVHDFileName = WScript.Arguments.Item(0)
  12: newVHDFileName = WScript.Arguments.Item(1)
  13:
  14: 'Connect to Virtual Server
  15: Set vs = CreateObject("VirtualServer.Application")
  16:
  17: 'Create VHD object
  18: set aVHD = vs.GetHardDisk(aVHDFileName)
  19:
  20: 'Merge the VHD to a new dynamic disk
  21: if aVHD.type = vmDiskType_Differencing then
  22:   wscript.echo "Merging the VHD to a new file..."
  23:    set VMTask = aVHD.MergeTo(newVHDFileName, vmDiskType_Dynamic)
  24:    vmTask.WaitForCompletion(-1)
  25: end if

Questions or comments, check out Ben's original post on his Blog, here.

Published Monday, March 12, 2007 6:43 AM 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
<March 2007>
SuMoTuWeThFrSa
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567