HowTo: Attach VHD files upon startup – Windows 7

less than 1 minute read

Unfortunately there is no build-in easy way to do that. Fear not, with some scripting we can handle this.

  • Create a batch file and modify the path to VHD.
@echo off
SET TEMPFILE="%TEMP%\%RANDOM%.TXT"
echo SELECT VDISK FILE="C:\full\path\to\license.vhd">%TEMPFILE%
echo ATTACH VDISK>>%TEMPFILE%
DISKPART /s %TEMPFILE%
del %TEMPFILE%
  • Save the script to your path of preference.
  • Open Task Scheduler

  • Open Task Scheduler.
  • Click on Create Task on the right tab.
  • Give a name to the task. Click on Change User or Group and choose Administrators for the group.

  • Click on Triggers. Choose At Startup

  • Click on Actions. Create New Action. Point to batch file you created earlier.

  • Save the task. When you restart your computer, VHD will automatically mounted.

Leave a Comment