> -----Original Message-----
> From: Alexander Suhovey [private.php?do=newpm&u=]
> Posted At: Friday, October 20, 2006 7:18 PM
> Posted To: microsoft.public.win2000.cmdprompt.admin
> Conversation: How to assign a drive letter to a volume by name (not
> driveumber)?
> Subject: Re: How to assign a drive letter to a volume by name (not
> driveumber)?
>
> > -----Original Message-----
> > From: Michael [private.php?do=newpm&u=]
> > Posted At: Thursday, October 19, 2006 6:21 PM
> > Posted To: microsoft.public.win2000.cmdprompt.admin
> > Conversation: How to assign a drive letter to a volume by name (not
> > driveumber)?
> > Subject: Re: How to assign a drive letter to a volume by name (not
> > driveumber)?
> >
> > Hello Alexander
> > thanks for your answer. That sounds a good solution. I would
> appreciate
> > very
> > much if you send me an example
> > ciao
> > MIChael
> >
> > "Alexander Suhovey" <(E-Mail Removed)> schrieb im Newsbeitrag
> > news:003301c6f386$c40c3760$(E-Mail Removed)...
> > >> -----Original Message-----
> > >> From: Michael [private.php?do=newpm&u=]
> > >> Posted At: Thursday, October 19, 2006 1:13 PM
> > >> Posted To: microsoft.public.win2000.cmdprompt.admin
> > >> Conversation: How to assign a drive letter to a volume by name
> (not
> > >> driveumber)?
> > >> Subject: How to assign a drive letter to a volume by name (not
> > >> driveumber)?
> > >>
> > >> Hello
> > >>
> > >> I know how to assign a drive letter to a volume with diskpart.
> > >>
> > >> But diskpart has the disadvantage that you have to name the
> volume
> > by
> > >> its
> > >> volumenumber. And the volumenumber may change so the script
> > gives
> > >> the wrong
> > >> drive the letter.
> > >>
> > >> Is there a way or scripting tool to assign a drive (volume) a
drive
> > > letter
> > >> by selecting the name of the drive?
> > >>
> > >> Thank you very much for help!
> > >>
> > >> MIchael
> > >
> > > Michael,
> > >
> > > By "name of the drive", do you mean volume label? If yes, you can
> > first
> > > run diskpart /s script.txt with "list volume" command inside
> script.txt
> > > and parse output of the command to find volume number based on
> > known
> > > volume label. There's two caveats however. Note however that
> > diskpart
> > > shows only first 11 characters of volume label.
> > >
> > > If you need a batch example, let me know.
> > >
> > > --
> > > Alexander Suhovey
> > >
>
> Here we go:
> ======start batch script=======
> @echo off
> setlocal ENABLEDELAYEDEXPANSION
> :: Full path to diskpart.exe. Defaults are:
> :: Windows 2000: "C:\Program Files\Resource Kit\diskpart.exe"
> :: 2003/XP: "C:\windows\system32\diskpart.exe"
> set dp=c:\windows\system32\diskpart.exe
>
> :: Volume label
> set label=MY_VOLUME_LABEL
>
> :: Temporary command file for diskpart.exe
> set dps="%TEMP%\dp.txt"
>
> echo list volume>%dps%
> echo exit>>%dps%
> set label_short=%LABEL:~0,11%
> if exist %dp% (
> for /f "delims=" %%i in ('%dp% /s %dps%') do (
> set string=%%i
> if not "!string:%label_short%=!"=="!string!" (
> set volnum=!string:~9,3!
> set volnum=!volnum: =!
> )
> )
> if not "!volnum!"=="" (
> echo Volume Label: %label%
> echo Volume Number: !volnum!
> ) else (
> echo Cannot find volume with label %label%
> )
> ) else (
> echo Cannot find %dp%&goto :EOF
> )
> =======end batch script========
> --
> Alexander Suhovey
There's limitation however: If you have several volumes that have labels
with same first 11 characters, script will assgn number of last such
volume found to VOLNUM variable.
--
Alexander Suhovey
|