locked
To create a blank virtual disk file using the file explorer context menu > New > Hard Disk Image File RRS feed

  • General discussion

  • I just have to empty a SD card; compressing its contents to a 7zip-file takes too much time, and if I have to access the files quickly, I prefer to use a mountable filetype. Thus the requirement to quickly create a VHDX-file, then mount it using the context menu.

    Tested using Windows 8.1 without Hyper-V-Role installed.

    First, you need to create an empty vhdx-File as a template.

    You already have to specify the maximum size this vhdx is allowed to expand to, in my case 255 GiB (255 GiB × 1024 MiB/GiB = 261120 MiB). This can be placed in either your user profile or shared for all users:

    • Current User: C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Templates\
    • All Users: C:\ProgramData\Microsoft\Windows\Templates\

    To create the template:

    1. Start an elevated command prompt

    2. Run diskpart.exe

    3. Enter the following commands:

    create vdisk file=C:\ProgramData\Microsoft\Windows\Templates\Virtual-Hard-Disk.vhdx type=expandable maximum=261120 attach vdisk create partition primary format fs=ntfs label="Blank Virtual Disk" quick assign letter=z detach vdisk exit

    4. Once the template is in place, just run this command:

    reg.exe add HKCR\.vhdx\Windows.VhdFile\ShellNew /f /v FileName /t REG_SZ /d Virtual-Hard-Disk.vhdx

    Voilà!

    Now you just have to right-click in any file explorer window, also on remote network shares, select New > Hard Disk Image File and rename the file as you wish!

    L.

    Saturday, May 25, 2019 8:39 PM