Jump to content











Photo
- - - - -

list mounted images from command line


Best Answer Olof Lagerkvist , 23 September 2020 - 10:32 AM

Yes, you can use -u or -m parameters:

imdisk -l -u 0

or

imdisk -l -m D:
Go to the full post


  • Please log in to reply
6 replies to this topic

#1 Azev

Azev

    Member

  • Members
  • 34 posts
  •  
    Brazil

Posted 23 September 2020 - 09:48 AM

Hi,

 

Is it possible to get what image files are mounted with imdisk?

 

imdisk -l will show only the mounted points but not the image file mounted

\Device\ImDisk0
\Device\ImDisk1
\Device\ImDisk2

for example, ImDisk2 is an .iso image that was mounted from a batch script. I'd like to get the path to the mounted .iso file.

 

Thanks



#2 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 23 September 2020 - 10:32 AM   Best Answer

Yes, you can use -u or -m parameters:

imdisk -l -u 0

or

imdisk -l -m D:

  • Azev likes this

#3 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 23 September 2020 - 01:40 PM

 

Yes, you can use -u or -m parameters:

 

Which means, no :w00t: :ph34r:, you need to re-iterate another command, once for each IMDISK device found.

I.e. more or less:

@ECHO OFF
REM IMLIST.CMD
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F "tokens=1,2 delims=k" %%A IN ('imdisk -l') DO (
SET ThisDevice=%%B
REM imdisk -l -u !Thisdevice!
CALL :get_device_data !ThisDevice! 
)
GOTO :EOF

:get_device_data


FOR /F "tokens=1,2,* delims=: " %%C IN ('imdisk -l -u %1') DO (
IF "%%C"=="Drive" SET This_Drive=%%E
IF "%%C"=="Image" SET This_Image=%%E
IF "%%C"=="Size" ECHO \Device\Imdisk%1 !This_Drive!: !This_Image!
)

:duff:

Wonko



#4 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

  • Developer
  • 1448 posts
  • Location:Borås, Sweden
  •  
    Sweden

Posted 23 September 2020 - 01:44 PM

Thanks! Small modification, you need -n switch to imdisk -l to get just the device number and not \Device\ImDisk0 etc.

@ECHO OFF
REM IMLIST.CMD
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F %%A IN ('imdisk -l -n') DO (
SET ThisDevice=%%B
REM imdisk -l -u !Thisdevice!
CALL :get_device_data !ThisDevice! 
)
GOTO :EOF

:get_device_data


FOR /F "tokens=1,2,* delims=: " %%C IN ('imdisk -l -u %1') DO (
IF "%%C"=="Drive" SET This_Drive=%%E
IF "%%C"=="Image" SET This_Image=%%E
IF "%%C"=="Size" ECHO \Device\Imdisk%1 !This_Drive!: !This_Image!
)

Edit: No, you don't need that since you fixed that with tokens and delims. Sorry. But anyway, we could simplify using -n.



#5 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 23 September 2020 - 02:08 PM

Edit: No, you don't need that since you fixed that with tokens and delims. Sorry. But anyway, we could simplify using -n.

Yep :), using "k" as delim worked, but with -n it is much cleaner. :thumbsup:  

Added check for "No device":

@ECHO OFF
REM IMLIST.CMD
SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F %%A IN ('imdisk -l -n') DO (
SET ThisDevice=%%B
REM imdisk -l -u !Thisdevice!
IF "!Thisdevice!"=="%%B" ECHO No imdisk device. &&GOTO :EOF
CALL :get_device_data !ThisDevice! 
)
GOTO :EOF

:get_device_data
FOR /F "tokens=1,2,* delims=: " %%C IN ('imdisk -l -u %1') DO (
IF "%%C"=="Drive" SET This_Drive=%%E
IF "%%C"=="Image" SET This_Image=%%E
IF "%%C"=="Size" ECHO \Device\Imdisk%1 !This_Drive!: !This_Image!
)

:duff:

Wonko



#6 Azev

Azev

    Member

  • Members
  • 34 posts
  •  
    Brazil

Posted 23 September 2020 - 04:57 PM

Thanks guys! very helpful!


  • Olof Lagerkvist likes this

#7 Azev

Azev

    Member

  • Members
  • 34 posts
  •  
    Brazil

Posted 26 September 2020 - 02:20 PM

Of course! imdisk.cpl will show you that.
No need for all these scripts. :jaclaz:

As I wrote, the context is BATCH and scripting. Don't try to play smart on me. Read the post again instead.

Of course I know i can use the control panel.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users