用VB脚本将VHD虚拟硬盘挂载到Longhorn物理机上
我们知道微软的Longhorn内置的Hyper-v虚拟化技术相当强大,通过管理控制台可以将以前Virtual PC和Virtual Server 2005中建立的VHD虚拟硬盘加载到VM中。但是,如果想要把VHD挂载到宿主的系统上去,怎么办呢?当然有办法了,用VB脚本来实现。
Option Explicit
Dim WMIService
Dim VHDService
Dim VHD
'Specify the VHD to be mounted
VHD = "D:\Test.vhd"
Set WMIService = GetObject("winmgmts:\\.\root\virtualization")
Set VHDService = WMIService.ExecQuery("SELECT * FROM Msvm_ImageManagementService").ItemIndex(0)
VHDService.Mount(VHD)
注意:此脚本只在安装了Hyper-v的Windows Server 2008上运行。