Comments on: Mounting VHDs in Windows 7 from a command-line script https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/ Home to Nic Jansma, a software developer at Akamai building high-performance websites, apps and open-source tools. Sat, 15 Dec 2018 18:42:20 +0000 hourly 1 https://wordpress.org/?v=5.5.3 By: Valentin https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1245284 Sat, 15 Dec 2018 18:42:20 +0000 http://nicj.net/?p=1135#comment-1245284 Thanks for the helpful post. I know this a rather old post, but if others like me still find it when googling for this question, here an addendum: instead of using the /s parameter and temporary files, you might as well use one-liners like this:

:: mount an image
(echo select vdisk file=”[location of vhd]” & echo attach vdisk) | diskpart

:: unmount an image
(echo select vdisk file=”[location of vhd]” & echo detach vdisk) | diskpart

Works both in CMD shell and batch scripts.

]]>
By: Alain https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1244839 Fri, 30 Mar 2018 08:58:20 +0000 http://nicj.net/?p=1135#comment-1244839 Thank you very much!

Now when I turn on the computer, Windows 10 runs a .bat that is on startup directory. That bat runs this:

c:\MountVHD.lnk C:/myHardDisk.vhd E

The .lnk is a Shortcut to your MountVHD.cmd but with Administrator privileges.

Very easy to use, thank you!!!

]]>
By: BoBo https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1231316 Mon, 29 May 2017 06:37:29 +0000 http://nicj.net/?p=1135#comment-1231316 Just in case you’re interested to automate that task have a look at Autohotkey (free, open source) an its “Run”-command set (beside its other options, eg to compile your cmd-snippets).

Greetz :o)

]]>
By: Zoli1972 https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1230572 Mon, 01 May 2017 19:57:13 +0000 http://nicj.net/?p=1135#comment-1230572 The access denied issue even occurs, if the VHD image isn’t BitLocker protected. What’s going wrong? Starting the script with elevated privileges (as an admin via UAC). Turning off the UAC is not a safe plan to me.

]]>
By: gugu https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1228912 Tue, 14 Feb 2017 16:29:50 +0000 http://nicj.net/?p=1135#comment-1228912 @braxsoft.com – yes, this seems to be a problem in WIndows 10 only.

The “attach” command causes an “access denied” prompt to appear if the VHD is BitLocker-protected. Extremely annoying and doesn’t happen in earlier versions of Windows.

]]>
By: Anonymous https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1227576 Thu, 24 Nov 2016 16:10:11 +0000 http://nicj.net/?p=1135#comment-1227576 @broxsoft.com
You can add to the script the following:
manage-bde -unlock -pw

For example
manage-bde -unlock D: -pw

The only thing is with bitlocker, you are required to type a password so you’ll need to key it in when the script prompts you

]]>
By: broxsoft.com https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-1221695 Tue, 14 Jul 2015 00:40:09 +0000 http://nicj.net/?p=1135#comment-1221695 This does not work with VHDs that are protected by Bitlocker.

]]>
By: Sergei Belous https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-82915 Fri, 22 Feb 2013 18:10:17 +0000 http://nicj.net/?p=1135#comment-82915 Nic, sorry for my bad English. This problem occurs only if Winodws7 virtual drive is not connected once. The first time you plug in the drive, the system installs the driver and possibly assign a drive letter itself. In Winodws 8, this is not a problem. I need to mount a virtual disk in WinPE 3.5. I’ve been looking for a solution and found your tool. Maybe you can help me write a script that requires a drive letter, but I don’t know how to do it. Thanks for the reply!

]]>
By: Nic https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-82913 Fri, 22 Feb 2013 14:42:02 +0000 http://nicj.net/?p=1135#comment-82913 In reply to Sergei Belous.

Strange, I haven’t seen this problem before. Do you see any errors in the Windows System or Application Event Log?

Is anything listed in regedit under HKLM\System\MountedDevices for H?

]]>
By: Sergei Belous https://nicj.net/mounting-vhds-in-windows-7-from-a-command-line-script/comment-page-1/#comment-82912 Fri, 22 Feb 2013 10:14:43 +0000 http://nicj.net/?p=1135#comment-82912 Hi Nic. Thank you. I found very helpful. But there is a problem to assign drive letters. When I run – C: \> MountVHD.cmd xxxx.vhd H, the system assigns a drive letter to another, and still I get the window http://picsee.net/upload/2013-02-22/74830f3172a3.jpg you have any ideas to help me.

]]>