If you have played with the new VHD feature in windows 7 or windows 2008 then you know just how cool of a feature this is. However the problem is that when you reboot your machine you find that when it comes back up all your VHD files are no longer attached? Here is what I did to get around the issue.
select vdisk file="c:\path to vhd files\myvhddrive.vhd" attach vdisk I named my script file diskpartscript.txt and placed it in the same folder as my VHD files.
Create a scheduled task that will automatically run when your machine starts up.
Related posts
Oscar said:
That's a clever trick. I just wish we didn't have to do these kinds of things and just keep the VHDs mounted at boot, like a network drive. But Thanks for posting this workaround.
jscott said:
Agreed, hopefully MS will enhange the VHD support so that one day we can define in disk manager that a VHD should persist after reboots.
Jim Prusa said:
This works only if I set the trigger to at log on rather than at startup. Windows 7. Any ideas?
Jim, here is some things to check. Edit the scheduled task and go to the General Tab Make sure "Run whether user is logged on or not" is selected I also have checked "Run with highest privileges" Triggers Tab Trigger "At Startup" Status "Enabled" See if those settings look the same?
Thanks much -- that did the trick. I had everything correct except I had not checked "Run with highest privileges." Obviously this allows the VHD to install with administrative privileges. Thanks much!
K. said:
Thank you for posting such a useful tutorial! It worked like a breeze after adjusting the admin settings the way Jim and J. suggested for Win 7. Thanks everyone for sharing your skills!
Ben said:
Thank you for this post! However in my case I have to wait about 3 minutes after booting before I can login and have the VHD attached and mounted. When I don't wait long enough it will not have been attached and mounted yet. Is there something I can do to speed up the process of attaching and mounting? "Run whether user is logged on or not" and "Run with highest privileges" are both selected. On the system run two Windows services (PostgreSQL and MapGuide) which depend on the VHD being attached and mounted because they access their data on it. Because the VHD is not accessible on time these services fail to start and need to be manually started afterwards. The VHD also contains a folder with a web application (IIS). The system is being used for demonstration purposes and the VHD gets copied between a couple of different physical machines. This way updates to the data and web application only need to be applied once on one system and afterwards the VHD gets copied over to the other machines.
trevor said:
Ok that works great, but the issue I have is the VHD is a shared drive with permissions, so this does not do much for me because I still have to login and share the drive and add permissions. Any ideas on how to solve this issue? Thanks!
Howard Sartori said:
Great methods here! But it fails on my PC. Location is not available I:\is not accessible. The media is write protected. What policy do I need to enable, even for Administrators Thanks. /Howard
Kelly R. said:
Thanks for this GREAT tip! And to jscott for the additional help! I just created my first VHD as I am learning Wordpress and needed to install Uniserver, so I wanted a VHD. I just restarted today, and I was like O_O. I found a bunch of guides, but they don't explain enough. The language is unnecessarily complicated & redundant on the Windows 7 site. Oh and if any1 were to hit my website url, I am in the process of learning Magento and Wordpress to put my store and blog and whatever else there for our new business. <--- not a techie, lol
DotNetKicks.com said:
Automatically attaching VHD files in Windows 7 and Windows 2008 You've been kicked (a good thing) - Trackback from DotNetKicks.com
Add comment