We hope you had an opportunity to look at the ISO Mounting Windows 8 Blog post. Native support for accessing ISO/VHD files was one of the most requested features for Windows 8. In Windows 8, you can directly mount ISO/VHD files from Windows Explorer and the content is available to you within clicks.
Here is a quick refresher on ISO and VHD files.
An ISO file is a file container that contains all information needed to put the contents on a CD or DVD or Blu-Ray. ISO Mounting Windows8 Blog post explains the format well and we encourage you to read it for more information.
A Virtual Hard-Disk is a representation of a disk in a file which is treated as a physical disk by the Windows. Since it is a file, it can be moved around and provides portability unmatched by physical disks. For more in-depth information on VHD format, we encourage you to read the VHD File Format Specification.
Note: A Virtual Hard Disk (VHD) is a different concept than a Virtual Disk as exposed by the Storage PowerShell module. For more information on Virtual Disks, see the blog post: An Introduction to Storage Management in Windows Server 2012
In this blog post, we look at some common scenarios and PowerShell Cmdlets for ISO/VHD mounting.
Sharing Content on ISO / VHD File with Others
Whether at home or at office, all of us have faced the need to access the contents of an ISO/VHD file. We want to share contents with others quickly and in an easily accessible manner. Windows 8 makes it easy.
To view the contents of an ISO file, you can mount an ISO/VHD by selecting “Mount” option in Explorer Ribbon, double click on the file or right click to select mount option. Windows Explorer will show you the contents immediately. Example shown here uses ISO image of Windows 8.
This post will not discuss mount and eject operations in details. ISO Mounting Windows 8 Blog post covers basic operations in great depth.
Installing software application using ISO Mounting
When software is distributed in form of ISOs, the ISO contents has to be accessible in order to install the software. With ISO Mounting, you don’t have to burn the ISO to an optical disc or use third party software. However, there are cases where installing software after mounting the ISO file may not be very straight forward. We discuss two scenarios in this post.
Determining which executable to run in order to install a software application
When an optical disc containing software installation is inserted, if the software company has specified what executable to run, Windows will run it automatically for you. This behavior is commonly known as Autorun. Autorun is configurable but we will not discuss it in detail in this blog post. When the ISO is mounted, Windows creates a Virtual CD-ROM for you. To protect against malicious software, Windows blocks autorun on this Virtual CD-ROM. In order to figure out which executable to run, refer to the autorun.inf file located on the Virtual CD-ROM.
In the following example that uses “Windows 8” ISO image, autorun.inf tells the executable that should be run in order to install Windows 8. If the Virtual CD-ROM was assigned the drive letter d:, then setup.exe in the autorun.inf file would refer to d:\setup.exe.
Install a software application that requires multiple ISO files for installation
Some software applications require multiple discs for installation. When you put a disc in the optical drive and run the setup to install the software, the setup knows from where the setup is being run from and the associated drive letter. For example, if the optical drive has the drive letter d: associated with it, the setup knows that the setup files reside on d: drive. When the setup asks to take disc one out and put disc two in, setup may rely on the drive letter to know where to read the contents of disc two from.
In case of ISO Mounting, once disc one is ejected and the setup asks for disk two, ISO Mounting does not guarantee that the disc two will get the same drive letter upon mounting. The following example walks-through how to change the drive letter of a Virtual CD-ROM in order to complete the installation successfully.Open Disk Management by typing “Disk Management” in Start Screen and switch to Settings.
Disk Management UI will show the drive letter associated with the Virtual CD-ROM.
Right click on E: and select the option to “Change Drive Letters and Paths…”.
Select “Change” on the pop-up window to choose the desired drive letter. Windows 8 will now use the new drive letter for the Virtual CD-ROM.
ISO Mounting and Windows 8 Server
ISO mounting is not available on a default installation of Window 8 Server. It is an optional feature that must be enabled in order to mount ISO/VHD files from Windows Explorer. Launch Server Manager by typing “Server Manager” in the Start Screen.
In Server Manager, click on Manage and select “Add Roles and Features”.
Navigate to Features and select “Desktop Experience”.
Alternatively, PowerShell also may be used to install Desktop-Experience package. The picture below demonstrates how to use PowerShell to install Desktop-Experience package.
The machine has to be rebooted before the changes would take effect.
Note that on Windows 8 server, VHD and ISO files can be mounted only by an administrator. This allows admins to control content available to server users.
ISO Mounting and PowerShell
With Windows 8 Developer Preview we introduced you to native support for ISO/VHD Mounting. You gave us feedback, and we are delighted to know that you are excited about the feature. One of features requested by you was to provide scripting support for ISO/VHD Mounting and we have added PowerShell support to mount and eject ISO Files. We hope you enjoy the improvements.There are three Cmdlets for ISO mounting. Mount-DiskImage, Get-DiskImage and Dismount-DiskImage.Mount-DiskImage mounts a valid ISO/VHD file and requires full path of the file.
The Get-DiskImage cmdlet returns information about one or more disk images (ISO or VHD). This cmdlet could also be used to determine if the specified ISO or VHD file is mounted or not.
Get-DiskImage C:\Users\WinVMAdmin\Downloads\Windows8-ConsumerPreview-32bit-English.iso | Get-Volume
DisMount-DiskImage cmdlet can be used to eject an already mounted ISO/VHD file.
The following picture demonstrates the above Cmdlets
Getting the drive letter of a mounted VHD requires the use of few other Cmdlets. Just like a physical storage disk could have multiple partitions, a VHD can contain multiple partitions. In order to get the drive letter(s) assigned to the partitions of the mounted VHD, we need to query for partitions and then get volume information of each partition.
Get-DiskImage C:\Users\WinVMAdmin\Downloads\WS2008R2_EnterpriseCore_x64.vhd | Get-Disk | Get-Partition | Get-Volume
If only the drive letter is needed as output then following command would be helpful
(Get-DiskImage C:\Users\WinVMAdmin\Downloads\WS2008R2_EnterpriseCore_x64.vhd | Get-Disk | Get-Partition | Get-Volume).DriveLetter
Get-DiskImage Cmdlet is demonstrated in following picture.
We would love to hear how you are using ISO Mounting. Thank you for reading and enjoy Windows 8!!
Is there a Windows 8 API for this? How do I leverage this in my application.
Please look at OpenVirtualDisk, AttachVirtualDisk and DetachVirtualDisk methods on MSDN