Virtualization Automatically Mount VHD or VHDX File at Startup in Windows 11

  • Thread starter Thread starter Brink
  • Start date Published: Start date Updated Updated:
  • Tags Tags
    vhd

Drive_banner.webp

This tutorial will show you how to create an elevated task to automatically mount a VHD or VHDX file at startup for all users in Windows 10 and Windows 11.

Virtual hard disks (VHDs) are disk image file formats that have similar functionalities to a physical hard drive and are designed primarily for use with Hyper-V virtual machines.

When you attach a .vhd or .vhdx file, it will be mounted as a drive in File Explorer > This PC to open and access.

When you sign out, mounted VHD or VHDX files will not get unmounted, and will still be mounted and available the next time you sign in.

If you restart the computer, all mounted VHD or VHDX files will automatically get unmounted for all accounts.

If wanted, you can create an elevated task to automatically mount a VHD or VHDX file at startup instead of having to manually mount the VHD or VHDX file each time.

You must be signed in as an administrator to create an elevated task.




EXAMPLE: VHD or VHDX file mounted as drive in File Explorer

Mounted_VHD_in_File_Explorer_This_PC.webp




Here's How:

1 Open Task Scheduler (taskschd.msc).

2 Click/tap on Task Scheduler Library in the left pane of Task Scheduler, and click/tap on Create Task in the right Actions pane. (see screenshot below)

auto_mount_VHD_at_startup_task-1.webp

3 In the General tab, type a name (ex: "Mount VHD at Startup") you want for this task. (see screenshot below)

auto_mount_VHD_at_startup_task-2.webp

4 In the General tab, type a description (ex: "D:\VHD Example.vhdx") you want for this task. (see screenshot below)

I like to use the full path of the VHD or VDHX file as a quick reference of which file the task is mounting.


auto_mount_VHD_at_startup_task-3.webp

5 In the General tab, select (dot) the Run whether user is logged on or not box. (see screenshot below)

auto_mount_VHD_at_startup_task-4.webp

6 In the General tab, check the Run with highest privileges box. (see screenshot below)

auto_mount_VHD_at_startup_task-5.webp

7 In the General tab, select Windows 10 in the Configure for drop down menu. (see screenshot below)

auto_mount_VHD_at_startup_task-6.webp

8 Click/tap on the Triggers tab, and click/tap on the New button. (see screenshot below)

auto_mount_VHD_at_startup_task-7.webp

9 Select At startup in the Begin the task drop down menu, and click/tap on OK. (see screenshot below)

If you would like to delay this task from running at startup for a bit before prompting for the BitLocker password to unlock the drive, you can check the Delay task for box, and select how long of a delay you want after startup before this task automatically runs.


auto_mount_VHD_at_startup_task-8.webp

10 Click/tap on the Actions tab, and click/tap on the New button. (see screenshot below)

auto_mount_VHD_at_startup_task-9.webp

11 Type PowerShell in the Program/script field. (see screenshot below)

auto_mount_VHD_at_startup_task-10.webp

12 Type the command below into the Add arguments field, and click/tap on OK. (see screenshot below)

"Mount-DiskImage -ImagePath 'Full path of VHD or VHDX file'"​

Substitute Full path of VHD or VHDX file in the command above with the actual full path of the VHD or VHDX file you want automatically mounted at startup.

For example: "Mount-DiskImage -ImagePath 'D:\VHD Example.vhdx'"


auto_mount_VHD_at_startup_task-11.webp

13 Verify the details are correct for the command and full path of the VHD or VHDX file. (see screenshot below)

If it is not correct, click/tap on Edit, go back to step 12, and correct it.


auto_mount_VHD_at_startup_task-12.webp

14 Click/tap on the Conditions tab, uncheck the Start the task only if the computer is on AC power box, and click/tap on OK. (see screenshot below)

auto_mount_VHD_at_startup_task-13.webp

15 When prompted, enter the password of your Windows account, and click/tap on OK. (see screenshot below)

auto_mount_VHD_at_startup_task-14.webp

16 You will now see this new task (ex: "Mount VHD at Startup") listed in the Task Scheduler Library. You can now close Task Scheduler if you like. (see screenshots below)

You can Disable and Enable this task as needed.

You can Delete this task to remove it.


auto_mount_VHD_at_startup_task-15.webp
delete_auto_mount_VHD_at_startup_task-1.webp
delete_auto_mount_VHD_at_startup_task-2.webp



That's it,
Shawn Brink


 
Last edited:
Back
Top Bottom