A few days ago, I wrote about what seemed to be an elegant solution to the problem of mounting VHD files within Server 2008 without installing IIS and Virtual Server 2005. Ravi Chaganti came up with a combo VBS and REG file that added the nifty "Mount" and "Dismount" commands to a VHD file. However, mounting a VHD didn't actually bring it online. You could do that in Disk Management, but I was looking for a more automated solution.
And Ravi supplied it, here: http://www.ravichaganti.com/blog/?p=116. This is a batch file that invokes the DISKPART utility, first to figure out the number of the disk that's offline, then to select it and bring it online.
In order to make this script work on Server 2008's version of DISKPART, I had to make two edits to Ravi's script. First, in the FOR loop on line 15, change the capitalization from "offline" to "Offline". Second, in line 23, change "online" to "online disk", so that the full line reads as follows:
echo online disk >> %temp%\vhdonline.dps
When you're done, you can test the batch file separately. Then you can invoke it daisy-chain style from VHDMOUNT.VBS using the WshShell.Run method, as Ravi suggests. Sweet!
Recent Posts:
Glenn Weadock is a longtime instructor for Global Knowledge and teaches Windows 7, Server 2008, and Active Directory. He has recently co-developed with Mark Wilkins two advanced Server 2008 classes in the Microsoft Official Curriculum. Glenn also consults through his Colorado-based company Independent Software, Inc. and is technical director of MarketCoach Investment Education Software LLC.