AUTOMATE ATTACHING VIRTUAL HARD DRIVES (in Windows 7)

Assumptions:

The virtual hard drives and related scripts are all located in C:\VirtualDrive.
The Virtual Hard Drive (VHD) name is VirtualDocs.vhd.

Create VirtualDriveScript.txt in C:\VirtualDrive to include the following lines:

Select vdisk file=”C:\VirtualDrive\VirtualDocs.vhd"           
Attach vdisk

Notes:

For multiple VHDs, these 2 lines must be replicated for each VHD using the appropriate VHD name.
You don’t need to assign the drive letter, IF the drive letter was previously assigned to the drive AND the drive letter isn’t currently in use by another drive.
If you need to assign drive letters, its best to create TXT scripts for each VHD AND add the following line after the attach vdisk line.

                Assign letter=V (or whatever drive letter is appropriate)

Create AttachVhd.bat in C:\VirtualDrive to include the following lines:

diskpart /s “C:\VirtualDrive\VirtualDriveScript.txt

Notes:

Diskpart /s – indicates to run a script
For multiple scripts for attaching each VHD, repeat the above (diskpart /s …) line using the appropriate TXT script name in AttachVhd.bat.

Open Task Scheduler using 1 of the following methods:

Start > Control Panel > Administrative Tools > Task Scheduler
Start > RC Computer > Manage > Task Scheduler
Start > Accessories > System Tools > Task Scheduler
Start > TaskSchd.msc

Select Create Basic Task in the Action pane or Action tab

CREATE A BASIC TASK
Name:  Attach Virtual Drive at Startup
Next

TASK TRIGGER
Select  When the computer starts
Next

ACTION
Select  Start a program
Next

START A PROGRAM
Program/script:  C:\VirtualDrive\AttachVhd.bat
Next

SUMMARY
Check box for  Open the Properties dialog for this task when I click Finish
Finish

ATTACH VIRTUAL DRIVE AT STARTUP PROPERTIES (Local Computer)
GENERAL tab
Check box for  Run with highest privileges
Change Users or Groups
button

SELECT USER OR GROUP
Enter the object name to select:  SYSTEM
Check Names
button
OK

ATTACH VIRTUAL DRIVE AT STARTUP PROPERTIES (Local Computer)
GENERAL tab
OK