Getting the full path to NTLite's mounted image directory

garlin

Moderator
Staff member
Do you need to run automated scripts on NTLite's mounted image folder?
But it's not always assigned to [Temporary directory]\NLTmpMnt01

We can use DISM (on Win 10/11 hosts) to report the mount folder's current path. Using the MountFolder value, you can find which files to edit.
Insert your script commands below the comment line.

CMD:
Code:
@echo off
setlocal
for /f "tokens=2,* delims=\" %%a in ('dism /get-mountedimageinfo ^| findstr /C:"Mount Dir"') do set MountFolder=%%b

if "%MountFolder%" == "" (
    echo Exiting. No image mounted.
    exit /b
)

REM begin here
echo "%MountFolder%"

endlocal

PowerShell:
Code:
$ImageInfo = Get-WindowsImage -Mounted

if ($ImageInfo.MountStatus -ne "Ok") {
    Write-Output "Exiting. No image mounted."
    exit 0
}

$MountFolder = $ImageInfo.Path.TrimStart('\\?\')

# begin here
Write-Output "`"$MountFolder`""
 
Just a warning, since I used to do something like this a long time ago...

If, for some reason, you have more than one image mounted, you may inadvertently modify the wrong image with this script. (Learned the hard way, lol.)
 
Or from registry :)
Code:
for /f "tokens=3*" %%a in ('reg.exe query "HKLM\SOFTWARE\Microsoft\WIMMount\Mounted Images" /s /v "Mount Path" 2^>nul ^| findstr /i /c:"Mount Path"') do echo "%%b"
 
Back
Top