Sign in to follow this  
Followers 0
MattNis

Get Volume Number?

6 posts in this topic

How can I get the volume number of a CDROM?

I need to know which letter is for CDROM0, CDROM1, etc....The drive letters are not necessarily in the same order as the the volume numbers.


[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you want a reverse lookup for the volume name, test out this:

MsgBox(1,"VolumeName is",vol("VolumeName"))
; use would be $Driveletter=vol("VolumeName")

Func vol($volume)
    $drive=StringSplit ("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",","); I am lazy
    For $x=1 To 26; still 26 letters right?
$var = DriveGetLabel( $drive[$x]&":\" )
; note this returns 1 if none found, or drive doesnt' exist
;If $var<>"1" Then MsgBox(4096,"Volume Label:",$drive[$x]&":\"& $var); if you want to watch it work, uncomment this line
    If $var=$volume Then Return $drive[$x]&":\"
Next
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

DriveGetDrive ( "CDROM" )

:whistle:

Share this post


Link to post
Share on other sites

Thank you for your replies, but none of the solutions are what I wanted.

I tried DriveGetLabel before and it doesn't do what I need.

If you right click on My Computer and choose Manage, then click on Disk Management

You will see Disk 0, and perhaps Disk 1, Disk 2, etc depending on how many drives you have

You will also see CDROM0, CDROM1, CDROM2, depending on how many cdroms you have.

now, each harddrive may have several partitions, and the drive letters could be randomly scattered across drives

Disk 0 = C, G, K

Disk 1 = D, L, Z

CDROM0 = H

CDROM1 = Q

I want to use DiskPart as a command line tool to rename the user's CDROM, (the very cdrom that they are running my script from) to a different letter. They could run this from either cdrom0 or cdrom1....and I do not know what letter it will be until they actually run the script.

DiskPart takes the volume number as a parameter. When there is just one cdrom, I tell it to rename Volume 0 and we're all safe. But if there is more than one.....

then if he runs it from drive Q, I want to rename Volume 1 to some other letter, otherwise rename Volume 0 to some other letter.

Maybe I'm just missing a simple solution...

DriveGetDriive just gives the drive letters in alphabetical order, and I'm not sure what other order it's capable of.

DriveGetLabel just gives the label, and not the volume number.

thank you much


[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Share this post


Link to post
Share on other sites

you could use diskpart to get the info into a file:

FileWriteLine ("coms.txt", "list volume" )
runwait(@comspec & '\diskpart /S coms.txt > result.txt')

then read result.txt in your script and findthe info you need ...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks

that works

but it takes a while...no less than 20 seconds for diskpart to finish...even on a P4.

I was just wondering if there's a built in way

but using diskpart itself works for the time being


[quote]I was busy waiting all night for the Columbus Day Bunny to come down my chimney and light fireworks in my pumpkin.There's so much wrong with that.Oh, I'm sorry, i forgot you were Jewish.[/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0