VHD - Auto-mount at Startup in Windows 8

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

information   Information
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.

Tip   Tip
If you like, you could also use Bitlocker to encrypt the VHD drive.




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]
[/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.​
SetupScript_1a_x.png


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'.
SetupScript_2a_x.png

4. Open the WIN+X Power User Tasks menu, and click/tap on Computer Management. (see screenshot below)
SetupScript_3.png


5. In Computer Management, select Task Scheduler on the left (point 1 on screenshot), then select Create Task (point 2 on screenshot).
SetupScript_4a.png


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.
Task_1a.png


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.

Note   Note
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.


Task_2a_Sub.png

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.​
Task_3a.png

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.
Task_4a.png

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.
Task_6a_Auth.png


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

  • Windows_Virtual_PC.png
    Windows_Virtual_PC.png
    15.2 KB · Views: 402
Last edited by a moderator:
Hi kremster,

I'm not an expert on the issues / benefits of mounting the SD card as C:\SDCard?

But since you're mapping the VHDX to a new drive letter anyway, what happens if you don't mount the SD card into C:\SDCard, and try to mount the VHDX from the SD card's original drive letter?

Even if it isn't what you want to do in the long term, it may help find a path to the solution.

So if your SD card was drive F:, for example, then instead of
Code:
select vdisk file="C:\SDCard\MyStuff.vhdx"
you'd have
Code:
select vdisk file="F:\MyStuff.vhdx"

Incidentally I had a tablet which wouldn't upgrade to Windows 10 build 1511 unless I removed the SD card.
 

My Computer

System One

  • OS
    Windows 8.1, 10
Hi,

I am using windows 10 home on a winbook TW700 16gb version.

The problem I have is windows 10 wants to install a new update but needs an additional 2.3 gb's on my C drive which I do not have. So one remedy users had for this was to create a VHD drive.

Now I am able to manually mount the VHD and install updates to it but of course that is useless as it doesn't auto mount on reboot which causes issues with the update process.

So I tried these steps using my own directory.

I made a text file at C:\Users\R\Documents\attachVHD.txt

The text file states this -

select vdisk file="D:Attach VHD.vhd"
attach vdisk

I saved that file to the location above.

Then I went into the task scheduler of windows 10.

I do not have screen shots but this is what I did

General tab

name - Mount VHD
location \
Author DESKTOP-TM3VC23\R
description auto mount VHD

Checked Run wether or not user is logged in and run with highest priviledges

Configure for windows 10


Triggers tab is at startup with nothing else checked or setup

Actions tab
Action start a program
program/script is diskpart
arguments is /s C:\Users\R\Documents\attachVHD.txt

Conditions tab has nothing checked

so I hit OK and enter my admin password and reboot
But then the VHD drive which is listed as E: VHD when manually mounted is not present.

What am I missing? I can manually mount but it is not auto mounting in windows 10.
 
Last edited by a moderator:

My Computer

System One

  • OS
    Windows 10 home
    Computer type
    Tablet
    System Manufacturer/Model
    winbook tw700
    Memory
    16gb
    Browser
    microsoft edge
It keeps asking me to insert my external media or sd card on reboot before getting to the log in screen with options to press OK or cancel.

BUT

now the VHD is auto mounting.

So how can I fix that error I get on startup boot? It is asking for my media to be inserted.
 

My Computer

System One

  • OS
    Windows 10 home
    Computer type
    Tablet
    System Manufacturer/Model
    winbook tw700
    Memory
    16gb
    Browser
    microsoft edge
Hello Durk, and welcome to Eight Forums. :)

It would be best to post this issue at our sister site www.tenforums.com instead since it's for Windows 10.
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
Hello Durk, and welcome to Eight Forums. :)

It would be best to post this issue at our sister site www.tenforums.com instead since it's for Windows 10.

If I post there I have to post all over this sucks.
 

My Computer

System One

  • OS
    Windows 10 home
    Computer type
    Tablet
    System Manufacturer/Model
    winbook tw700
    Memory
    16gb
    Browser
    microsoft edge
Copy and paste will make it easy.
 

My Computer

System One

  • OS
    64-bit Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Custom self built
    CPU
    Intel i7-8700K OC'd to 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G7 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    OCZ Series Gold OCZZ1000M 1000W
    Case
    Thermaltake Core P3
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gb/s Download and 35 Mb/s Upload
    Browser
    Internet Explorer 11
    Antivirus
    Malwarebyte Anti-Malware Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
You need to create a .cmd file that will mount the VHD upon startup...

The AttachVHD.CMD file states this -
@ echo off
DISKPART /s "C:\Users\R\Documents\attachVHD.txt"
Exit

the attachVHD.txt states this -

select vdisk file="D:Attach VHD.vhd"
attach vdisk
assign letter=X
exit

NOTE: the VHD (as listed above) is on the root of Drive / partition D > You can also pre-assign a mounted drive letter by replacing X

Triggers tab is at startup with nothing else checked or setup
Actions tab
Action start a program CMD
arguments is > C:\Users\R\Documents\attachVHD.CMD


I would move the CMD file to the same root drive (D) > so you will have the VHD File, TXT file and the CMD file to mount it, on the same partition..
 

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
So are you saying to make another text file for the .CMD? And then move both text files onto my CD card which is the D drive? I have 3 drives C is my main, D is my SD card and E is the VHD when it auto mounts. It is mounting but its not finding it when I have updates install to it to complete the update installations.
 

My Computer

System One

  • OS
    Windows 10 home
    Computer type
    Tablet
    System Manufacturer/Model
    winbook tw700
    Memory
    16gb
    Browser
    microsoft edge
You need to create a .cmd file that will mount the VHD upon startup...

The AttachVHD.CMD file states this -
@ echo off
DISKPART /s "C:\Users\R\Documents\attachVHD.txt"
Exit

the attachVHD.txt states this -

select vdisk file="D:Attach VHD.vhd"
attach vdisk
assign letter=X
exit

NOTE: the VHD (as listed above) is on the root of Drive / partition D > You can also pre-assign a mounted drive letter by replacing X

Triggers tab is at startup with nothing else checked or setup
Actions tab
Action start a program CMD
arguments is > C:\Users\R\Documents\attachVHD.CMD


I would move the CMD file to the same root drive (D) > so you will have the VHD File, TXT file and the CMD file to mount it, on the same partition..

Currently my text file for the automount is located in documents of my C drive.
 

My Computer

System One

  • OS
    Windows 10 home
    Computer type
    Tablet
    System Manufacturer/Model
    winbook tw700
    Memory
    16gb
    Browser
    microsoft edge
Back
Top