Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Automount VHD on windows 10

So here's a pretty neat thing, I use VHD's to organize the space on my computer. You can too!

  • Click Start

  • Type in the search bar "Disk par" =>

  • Click first result =>

  • In the program, click "Action" =>

  • Under action menu, click Create VHD =>

  • Make a new folder in your C: drive called VHD =>

  • now in "C:\VHD", add disk1.vhd

  • now finish setup =>

  • attach vhd

  • Now, in The same folder, create a new file "attach_vhd.txt"

  • in that file, place the following

select vdisk file="C:\VHD\coding.vhd"
attach vdisk
exit
  • save it

  • run the following command in PowerShell

schtasks /create /tn "automountvhd" /tr "diskpart.exe /s 'c:\VHD\attach_vhd.txt'" /sc ONLOGON /ru SYSTEM

and you're done

@laontme
Copy link

laontme commented Dec 24, 2020

To mount more drives in one step

select vdisk file="C:\VHD\coding.vhd"
attach vdisk
select vdisk file="C:\VHD\other.vhd"
attach vdisk
exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment