Mounting and unmounting an ISO image with the command prompt

Discussion in 'Windows 8' started by balubeto, Sep 1, 2014.

  1. balubeto

    balubeto MDL Addicted

    Dec 22, 2009
    581
    10
    30
    #1 balubeto, Sep 1, 2014
    Last edited: Sep 1, 2014
    Hi

    Using the command prompt (not Powershell) in Windows 8.1 update, how do I mount and unmount an ISO image?

    Thanks

    Bye
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. coleoptere2007

    coleoptere2007 MDL Guru

    Apr 8, 2008
    3,302
    1,939
    120
    You can mount an iso file with explorer by default but can't do any modifications on files.
     
  3. CorporateRAT

    CorporateRAT MDL Member

    Aug 4, 2012
    245
    45
    10
  4. Snuffy

    Snuffy MDL Expert

    Jan 7, 2008
    1,272
    630
    60
    I use DISM to mount and unmount

    mount
    DISM /Mount-Wim /WimFile: <wim_file> /Index: <image_number> /MountDir: <mount_directory>

    unmount
    DISM /Unmount-Wim /MountDir: <mount_directory> /Commit
     
  5. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,092
    24,400
    340
    #5 s1ave77, Sep 2, 2014
    Last edited by a moderator: Apr 20, 2017
    Hey Snuffy :D. This is to mount a WIM not an ISO as OP asked for.

    To mount an ISO:

    Code:
    powershell Mount-DiskImage -ImagePath "D:\pathtoyour.iso"
    To un-mount the ISO:

    Code:
    powershell Dismount-DiskImage -ImagePath "D:\pathtoyour.iso"
    To get the driveletter of the mounted ISO the ISOLABEL (mount ISO once to determine the label in properties) can be used:

    Code:
    for /f %%D in ('wmic volume get DriveLetter^, Label ^| find "ISOLABEL"') do set iso=%%D
    Check driveletter with powershell in cmd:

    Code:
    powershell Get-DiskImage -ImagePath "D:\pathtoyour.iso" ^| Get-Volume
    Code:
    Microsoft Windows [Version 6.3.9600]
    (c) 2013 Microsoft Corporation. Alle Rechte vorbehalten.
    
    C:\Windows\System32>powershell Mount-DiskImage -ImagePath "E:\IMAGES\DISC_IMAGES
    \Win.8.1.SE\Acronis2015Beta\Win8.1SE_x64.ISO"
    
    C:\Windows\System32>for /f %D in ('wmic volume get DriveLetter^, Label ^| find "
    Win8.1SE"') do set iso=%D
    
    C:\Windows\System32>set iso=G:
    
    C:\Windows\System32>powershell Get-DiskImage -ImagePath "E:\IMAGES\DISC_IMAGES\W
    in.8.1.SE\Acronis2015Beta\Win8.1SE_x64.ISO" ^| Get-Volume
    
    DriveLetter FileSystemL FileSystem  DriveType  HealthStat SizeRemain       Size
                abel                               us                ing
    ----------- ----------- ----------  ---------  ---------- ----------       ----
    G           Win8.1SE    UDF         CD-ROM     Healthy           0 B    3.51 GB
    
    C:\Windows\System32>powershell Dismount-DiskImage -ImagePath "E:\IMAGES\DISC_IMA
    GES\Win.8.1.SE\Acronis2015Beta\Win8.1SE_x64.ISO"
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Snuffy

    Snuffy MDL Expert

    Jan 7, 2008
    1,272
    630
    60
    Your right as RAIN, Thanks for the correction...
     
  7. bear_aussie

    bear_aussie MDL Senior Member

    Jun 8, 2015
    276
    305
    10
    #7 bear_aussie, Oct 31, 2021
    Last edited: Nov 1, 2021
    i know im 7(!!!) yrs late but incase anybody wants the real answer to this question...
    its "no" :)
    i looked in2 wmic but afaict it cant spawn non-persistent object instances
    BUT heres 5 lines (real lines - the 1s that start with ' are coments) of vbscript that will do it 4u
    Code:
    ' this is exactly how the Mount-Diskimage PS cmdlet works internally BTW
    With GetObject("WinMgmtS:\\.\ROOT\Microsoft\Windows\Storage").Get("MSFT_DiskImage").SpawnInstance_()
        ' -ImagePath must be a full path
        .ImagePath = "C:\Users\User\Download\en-us_windows_server_version_2022_updated_october_2021_x64_dvd_b6e25591.iso"
    
        ' -StorageType switch: 0 for "unknown" (virtdisk.dll will guess), 1 for iso, 2 for vhd, 3 for vhdx
        .StorageType = 0
    
        ' the first parameter is -Access: 0 for unknown, 2 for read-write, 3 for read-only
        ' the second is -NoDriveLetter: false to assign a letter, true to attach imae but not give it a drive letter
        .Mount 3, False
    End With
    2 unmount, change
    Code:
    .Mount 3, False
    to
    Code:
    .Dismount
    (Dismount method takes no parameters)

    edit: works in winpe/winre if u have the WinPE-StorageWMI package installed too :D
    its installed by default since 2013 but earlier versions (and "naked" pe from the adk) will need it dism /add-package'd
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...