Coding Corner: Compacting a disk part II

Coding Corner: Compacting a disk part II

Rate This
  • Comments 2

On Tuesday I posted some information about creating a 'disk compaction' script (http://blogs.msdn.com/virtual_pc_guy/archive/2005/02/08/369509.aspx).  Today I am going to explain how to hook this script up with all your virtual hard disks directly from explorer.  This is actually surprisingly simple.  All you need to do is to copy the following into a text file (note - you will need to change the path for the VBscript appropriately for your system):

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell\Compact\command]
@="cmd /c cscript.exe /nologo \"C:\\temp\\compact.vbs\" \"%1\""

Rename the text file to 'compact.reg' and then double click on the file.  This will import the above registry fragment - which will allow you to now select 'compact' off of the right mouse button menu on any virtual hard disk - like this:

Coding Corner: Compacting a disk part II   Coding Corner: Compacting a disk part II

Cheers,
Ben

UPDATE:  I have been contacted by a couple of people about this post.  It turns out that the registry fragment above only works if you have both Virtual PC and Virtual Server installed on your system (like I do).  If you only have Virtual Server installed - you will need to use this registry fragment:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Virtual.Machine.HD\shell\Compact\command]
@="cmd /c cscript.exe /nologo \"C:\\temp\\compact.vbs\" \"%1\""

[HKEY_CLASSES_ROOT\.vhd]
@="Virtual.Machine.HD"

Leave a Comment
  • Please add 2 and 8 and type the answer here:
  • Post
  • Ben, will this work with Virtual PC as well as Server?
    I guess I could just go away and test it, but figured it was almost as quick to just ask 'the man'!

    blogger@iwhite.net will get to me, as would a comment here.

    Thanks mate
  • Hi Ian,

    You need Virtual Server installed to be able to use this - however if you have both Virtual PC and Virtual Server installed - you can use this script on .VHDs from both.

    Cheers,
    Ben
Page 1 of 1 (2 items)