Done MOUNTISO: Add support for VHD / VHDX files

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
Also I'd suggest: (1) a /RW option to mount VHDs in read/write mode (ignore for .ISOs), and (2) allow more than one mount point to be specified (again, useful only for VHD files.)
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
I've done it manually using DiskPart.exe.
First, SELECT the VDISK:
SELECT file="C:\Program Files\Windows XP Mode\Windows XP Mode base.vhd"
Then ATTACH it :
ATTACH VDISK

You can also create VDISK's based on another VDISK using the CREATE command.

When done, you DETACH VDISK.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
I've done it manually using DiskPart.exe.
First, SELECT the VDISK:
SELECT file="C:\Program Files\Windows XP Mode\Windows XP Mode base.vhd"
Then ATTACH it :
ATTACH VDISK

You can also create VDISK's based on another VDISK using the CREATE command.

When done, you DETACH VDISK.

Neat; you could wrap that in a batch file. I've been using the Disk Management console, as I don't need to mount VHDs very often.
 
Here's the .CMD files that I have been using in TCC to Mount/Unmount VHDs;
Code:
REM https://gist.github.com/nicjansma/9b82f28a77f306b0cfc0
@echo off
setlocal enabledelayedexpansion

if {%1}=={} (
    echo Usage: %~nx0 [vhd] [letter]
    exit /b 1
)
set vhdPath=%~dpnx1
set driveLetter=%2

if {!driveLetter!}=={} (
    echo Mounting !vhdPath!
) else (
    echo Mounting !vhdPath! to !driveLetter!:
)

REM
REM create dispart script
REM
set diskPartScript=%~nx0.diskpart
echo sel vdisk file="!vhdPath!">!diskPartScript!
echo attach vdisk>>!diskPartScript!

REM assign the drive letter if requested
if not {!driveLetter!}=={} (
    echo select partition 1 >>!diskPartScript!
    echo assign letter=!driveLetter!>>!diskPartScript!
)

REM Show script
echo.
echo Running diskpart script:
type !diskPartScript!

REM
REM diskpart
REM
diskpart /s !diskPartScript!
del /q !diskPartScript!

echo Done!

endlocal

Code:
REM https://gist.github.com/nicjansma/9b82f28a77f306b0cfc0
@echo off
setlocal enabledelayedexpansion

if {%1}=={} (
    echo Usage: %~nx0 [vhd]
    exit /b 1
)
set vhdPath=%~dpnx1

echo Unmounting !vhdPath!

REM
REM create dispart script
REM
set diskPartScript=%~nx0.diskpart
echo sel vdisk file="!vhdPath!">!diskPartScript!
echo detach vdisk>>!diskPartScript!

REM
REM diskpart
REM
diskpart /s !diskPartScript!
del /q !diskPartScript!

echo Done!

endlocal

Joe
 
Similar threads
Thread starter Title Forum Replies Date
R Declined MOUNTISO: show the drive letter assigned. Suggestions 4
Joe Caverly Done Add ability to DEL Stream from SYMLINK Suggestions 2
Joe Caverly Add VHD to @drivetype Suggestions 1
R Option to add tcc to Bash profile Suggestions 1
R Add Custom Message to commands Suggestions 2
mfarah Declined Implement an "Add TCC to the task bar" in the TCMD installer. Suggestions 2
C Declined Add switch to MOVE to not make empty destination folders. (COPY's /F) Suggestions 4
M Add "ReleaseID" (aka version or build) to ver output Suggestions 2
R Declined In setup, add back/refresh buttons. Suggestions 1
D Done Suggestion: Add VIEW option to open in same position as current window Suggestions 0
D Done BDEBUGGER: add cmdline option to set a breakpoint at a given line Suggestions 0
D Done TCEdit and BDEBUGGER: add cmdline switch to jump to given line Suggestions 2
R Done Add "Evaluate Expression" to Right-Click Context Menu in Batch Debugger Suggestions 3
S Add support for Git auto-completion Suggestions 0
R Declined wish-list: add a command to copy a file to clipboard. Suggestions 17
R Declined Install option: Add File Explorer Run As Adminstrator option Suggestions 14
Dmitry L. Kobyakov Done Add the possibility to comment the ENDIFF Suggestions 11
Charles Dye Declined Windows functions and command: Add syntax to specify HWND directly Suggestions 0
Charles Dye Done @SNAPSHOT: Add option to capture the entire virtual screen Suggestions 0
R Done Add Libraries and Multi-line In-Memory functions to Features List on Website Suggestions 1
R Done Add to Pause Help text re indenting the prompt Suggestions 0
C Done Add ability for inline image files for sendmail or similar Suggestions 2
WinLanEm Add commands and functions Suggestions 11
rps Declined Add auto-load directives to tcmd.ini Suggestions 3
fromano Declined Add library functions to shralias saving feature Suggestions 12
Joe Caverly Add a "Snippet" Menu to CMDebug and TCC Debugger Suggestions 0
D Done Add the ability to control syntax coloring via an environment variable or some other way Suggestions 3
Joe Caverly Add example .BTM code to TCC Debugger and CMDebug Suggestions 1
Alpengreis Done Add "Slow copy" (/WAIT) parameter to SYNC command Suggestions 1
A Declined Take Command/Debugger as a Visual Studio 2017 add-in/extension Suggestions 4
rps Declined Add optional parameters to @search Suggestions 4
rps Done Add PDIR switches Suggestions 1
rps Declined ECHO -- Add spacing option Suggestions 2
vefatica Done Add log2 to @EVAL Suggestions 3
rps Done Add exclusion ranges to @files Suggestions 0
D Done Add VIEW option to open in same position as current window Suggestions 0
R Done Add a .btm LIBRARY system Suggestions 12
N Done Add display options to new HASH function Suggestions 1
rconn Add a parameter to dir command to handle zip files as folders Suggestions 1
rconn add support for batch file projects Suggestions 0
rconn Add support for backpipes Suggestions 0
rconn Add option to run programs Elevated from toolbar buttons Suggestions 0
rconn In the Help tab let the user add links either to files or web pages, with an icon & label. Suggestions 0
W Done Add colorize to tree command? Suggestions 0
Phileosophos Done Please add options for scrollback buffer searching Suggestions 24
G Declined Add option to turn on file name case sensitivity Suggestions 6
nickles Done Add a "Mark all threads read" button Suggestions 3
B Done Add New INI Directive To Specify WIPE Default Pass Count Suggestions 0
S Declined Add /W(ipe) option to several commands Suggestions 17
C TC drop-zone to add a tab Suggestions 0

Similar threads