Jump to content











Photo
- - - - -

Mounting dynamically expanding VHD


  • Please log in to reply
62 replies to this topic

#51 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 15 January 2012 - 07:46 PM

Olof,

Using only Console commands, no PowerShell & vbs, what would be the shortest way to find an originating virtual disk file for a mounted drive letter. Or, is it possible to dismount it in such batch without finding its file? I'm thinking of some iterative & enclosed search loops... :) Like:

Diskpart

list vdisk

-------------  loop

select disk #

detail disk

if (separate drive letter, check the match with selected drive letter, separate file name if matches)

detach vdisk file=


in a loop to find matching drive letter and then link it to vdisk & source file... Is it the shortest way to go?

#52 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 15 January 2012 - 08:20 PM

Btw, what was the last batch you wrote - when was it? :victory:

Something it would take you a lot of time to understand, finished it no more than 1 hour ago.

BTW the %L has nothing to do with batch scripting, it is simply part of the look, observe, learn game.

:cheers:
Wonko

#53 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 15 January 2012 - 08:30 PM

Wonko

Present you work please...if not a secret. "Show me the money". Still playing a smart teacher without showing anything... From your answers in VHD_Mount thread, you have about the same level in writing batches (if anyone does it anymore) as in every other your product presented here - none to be accurate. :)

Trying to correct your errors on the fly (%L) - this trick doesn't work anymore. :devil:

What did you try to explore new for the last 10 years? OR, may be you earned self-claimed "expert" status... by goggling others work? :magic:

#54 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

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

Posted 15 January 2012 - 08:37 PM

Olof,

Using only Console commands, no PowerShell & vbs, what would be the shortest way to find an originating virtual disk file for a mounted drive letter. Or, is it possible to dismount it in such batch without finding its file?


You need to specify mounted drive letter or device number to unmount it. You cannot use the originating image file name to unmount. So I suspect you are looking for a solution for a problem that you think you will never experience. Or something like that.

#55 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 15 January 2012 - 08:48 PM

Thanks Olof,

I was referring to Diskpart - Detach Vdisk command, which requires Vdisk to be selected by pointing to its file: Select Vdisk File=c:test.vhd. Were you thinking about a different command? Perhaps, mountvol [drive:]path /d or such?

#56 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 15 January 2012 - 08:59 PM

Present you work please...if not a secret.

You are welcome :):
@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

IF NOT %7.==. SET N=%*

IF NOT DEFINED N CALL :I_

CALL :Do_ %N%

CALL :Do__ H %H%

CALL :Do__ L %L%

SET V=%H%%L%

SET V

GOTO:EOF





:Do_

SET /A H=256*%2+%3+256*%6+%7

SET /A L=%1+256*%4+%5

GOTO:EOF



:Do__

CMD /C EXIT /B %2

SET "%1=%=ExitCode%"

SET %1=!%1:~-4!

GOTO :EOF



:I_

FOR /L %%A IN (1,1,7) DO (

SET /P _%%A_=%%A?:

)

SET N=%_1_% %_2_% %_3_% %_4_% %_5_% %_6_% %_7_%

GOTO :EOF


Trying to correct your errors on the fly (%L) - this trick doesn't work anymore. :devil:


Well, it works on XP (32 bit) allright, it is well possible that Windows 7 and 64 bit version has something changed, but I doubt it. :dubbio:
You might notice how I never suggested you to use it, only reported what I had on my system and how that worked allright (as it does) so, no error whatsoever.

:cheers:
Wonko

#57 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

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

Posted 15 January 2012 - 09:02 PM

Thanks Olof,

I was referring to Diskpart - Detach Vdisk command, that requires Vdisk to be selected by pointing to its file: Select Vdisk File=c:test.vhd. Were you thinking about a different command?


Eh, yes, I thought we were talking about a VHD mounted with ImDisk, not mounted with diskpart vdisk. Maybe some misunderstanding somewhere? An ImDisk virtual disk (of any type) is unmounted using imdisk command with -d parameters and -m followed by drive letter and colon:
imdisk -d -m R:

With a context menu item you can specify %1 or %L placeholders to pass the object selected in Explorer. Now, Explorer will translate that to for example R: and not R: which will cause problems. Therefore I wrote a rundll32 compatible routine in imdisk.cpl that could handle R: style paths:
rundll32.exe imdisk.cpl,RunDLL_RemoveDevice R:

So, in that case you can use %1 or %L to pass R: to the script. Look at how this is done in ImDisk dismount context menu item defined in registry (as posted by wonko the sane recently).

#58 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 15 January 2012 - 09:06 PM

Still playing a smart teacher without showing anything...

Naah, actually trying to help you, evidently wasted time.

From your answers in VHD_Mount thread, you have about the same level in writing batches (if anyone does it anymore) as in every other your product presented here - none to be accurate. :)

I just posted one of my batches, see if in your debugger it works.


What did you try to explore new for the last 10 years? OR, may be you earned self-claimed "expert" status... by goggling others work? :magic:

Sure, that's how I learned the little I know, by listening to people that knew more than I did.

:cheers:
Wonko

#59 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 15 January 2012 - 09:12 PM

Thanks again Olof, I got it with Mountvol and your Reg example. :) Converting drive letter isn't a problem, though departing from Diskpart wasn't planned. :dubbio:


Wonko

Very helpful batch you posted - just what this forum community was looking for years. :buehehe: Probably taken from Rob van der Woude or such...for no use.

#60 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 16 January 2012 - 02:35 AM

Olof

Real problem with Mountvol is it removes previously assigned drive letter from the vdisk (Reg or Header - didn't check) with /d switch (mountvol e: /d). So next time the code needs to check, whether an attached VHD got a drive letter to avoid assigning different letters to the same VHD each time (which also requires a loop) - any ideas how to solve?

I tried fsutil - it can't dismount VHDs. It looks like CMD batching is a very convoluted way to address today's drive issues. :)

#61 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 16 January 2012 - 09:18 AM

Probably taken from Rob van der Woude or such...for no use.

Some ideas were actually taken from Rob van der Woude examples, and it has some use, actually a very definite one, BTW.

For NO apparent reason:
@ECHO OFF

SETLOCAL ENABLEEXTENSIONS

IF "%1."=="." (CALL %~dpnx0 R:\) ELSE (GOTO :Skip)

GOTO :EOF



:Skip

SET L_=%1

SET L_1=%1

SET L_1=%L_1:~0,2%

SET L_2=%1

SET L_2=%L_2:\=%

FOR /F "tokens=1 delims=:" %%? IN ("%1") DO SET L_3=%%?:

FOR /F "tokens=1 delims=\" %%? IN ("%1") DO SET L_4=%%?

SET L_5=%~d1



SET L_




:cheers:
Wonko

#62 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 17 January 2012 - 07:49 AM

Hi Olof,

If one wants to add a shell command to Context Menu that appears when clicking on empty space in WE File Frame (where list of files appears in an open folder), what Reg key that command should go to? :)

#63 Olof Lagerkvist

Olof Lagerkvist

    Gold Member

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

Posted 17 January 2012 - 09:11 AM

Hi Olof,

If one wants to add a shell command to Context Menu that appears when clicking on empty space in WE File Frame (where list of files appears in an open folder), what Reg key that command should go to? :)


As far as I know you cannot add anything to that menu by just adding a registry key, you would need a Shell Extension component instead.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users