PC Review


Reply
Thread Tools Rate Thread

How to assign a drive letter to a volume by name (not driveumber)?

 
 
Michael
Guest
Posts: n/a
 
      19th Oct 2006
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


 
Reply With Quote
 
 
 
 
Alexander Suhovey
Guest
Posts: n/a
 
      19th Oct 2006
> -----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

 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      19th Oct 2006
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
>



 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      20th Oct 2006
> -----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

 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      20th Oct 2006
> -----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

 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      20th Oct 2006
Hey you did it all!!!
Thank you very very much!!!!
your script works great and Im happy.
I tried it on my own but didnt manage it.
:-))))))))))
ciao
MIchael

"Alexander Suhovey" <(E-Mail Removed)> schrieb im Newsbeitrag
news:00e601c6f45a$ffebdf40$(E-Mail Removed)...
>> -----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
>



 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      21st Oct 2006

"Michael" <(E-Mail Removed)> wrote in message
news:4538f546$0$30320$(E-Mail Removed)...
> Hey you did it all!!!
> Thank you very very much!!!!
> your script works great and Im happy.
> I tried it on my own but didnt manage it.
> :-))))))))))
> ciao
> MIchael


You are welcome, Michael.

--
Alexander Suhovey

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I permanently assign a drive letter to my CDROM drive? I lose it... bnus440 Windows XP General 1 2nd Jan 2007 05:20 AM
Changing boot volume or system volume drive letter =?Utf-8?B?RGls?= Windows XP General 4 7th Feb 2006 04:44 AM
Can't assign drive letter to slave hard drive after reinstall of X =?Utf-8?B?bWN0YXpyMg==?= Windows XP Hardware 2 3rd Aug 2005 12:18 AM
system restore console doesn't assign drive letter to drive (andcan't boot anymore) Alex Hunsley Windows XP Help 0 8th May 2005 08:00 PM
Install doesn't assign drive letter to slave drive smcroy Windows XP Setup 3 21st Jun 2004 02:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:47 PM.