How to Auto-mount a VHD at Startup in Windows 8

This tutorial will help show you how to have a VHD auto-mount as a drive at startup in Windows 8.
You must be signed in as an administrator to complete these steps.
You must be signed in as an administrator to complete these steps.

Here's how...
1. To start with, create a VHD file, using the drive letter you want to use for this VHD.
NOTE: For example, I've created a VHD file called 'MySecureStuff.vhd' in the 'C:\MyVHDs' folder, and I want it to be mounted as drive H.
2. Open Notepad, and copy the text below into it. (Note I have struck out the third line as I believe it was incorrect and shouldn't be entered.)
Code:
select vdisk file="[COLOR=#ff0000][B]C:\MyVHDs\MySecureStuff.vhd[/B][/COLOR]"
attach vdisk
[DEL]assign letter=[COLOR=#ff0000][B]H[/B][/COLOR][/DEL]
[/DEL]
A) Change the 'file=' part of the first line to contain the full path to the VHD you created earlier in step 1.
B) Change the 'assign letter' to be the drive letter you wish to use.
3. In Notepad, save it as a .txt file, and close Notepad.
NOTE: For example, I've called mine 'AttachVHD_H.txt' and saved it in a folder called 'C:\MyVHDs\VHDLoadScripts'.
4. Open the WIN+X Power User Tasks menu, and click/tap on Computer Management. (see screenshot below)
5. In Computer Management, select Task Scheduler on the left (point 1 on screenshot), then select Create Task (point 2 on screenshot).
6. In the General tab, enter a name and description for your task. Change the radio buttons to 'Run whether user is logged on or not', and change 'Configure for:' to say Windows 8.
7. Select the Triggers tab, then click New to add a new Trigger. Change 'Begin the task' to say 'At Startup'. Optionally, you can also tick the 'Delay task for' checkbox and select 1 minute (see note below). Click on OK.

The reason I selected a 1 minute delay is because I plan to enable BitLocker. Delaying gives the computer the chance to prompt me to enter a Bitlocker password just after I login rather than having to manually find the drive and start BitLocker. If you aren't using BitLocker, I don't think there's any advantage in selecting the delay.
8. Select the Actions tab, then click New to add a new Action.
A) In the 'Program/Script' box enter diskpart.
B) In the 'Add arguments' box enter:
/s
followed by a space and then the full path and name of the script file saved in step 4. So in my example it is:
/s C:\MyVHDs\VHDLoadScripts\AttachVHD_H.txt
C) Click on OK.
9. Select the Conditions tab. Clear the two checkboxes to Stop if the computer switches to battery power and Start the task only if the computer is on AC power, then click on OK to create the task.
10. If a Task Scheduler dialog pops up, saying 'enter user account information for running this task' then enter the password for the administrator username.
WARNING: You will also need to update this if you ever change the password on this account.
11. Close Computer Management.
12. To test this works, restart your computer. When it restarts, you should find that after a minute, the new drive is mounted as drive H: (or whatever you selected).
That's it, you're done!
Attachments
Last edited by a moderator: