[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to read drive label

TPReal

9/19/2008 9:06:00 PM

Hello. I'd like to get the labels of the hard drives (partitions) on my
machine from within a program. Is there any universal Ruby command to do
it?

I'm on Windows, so I guess I could use some WinAPI to do that but I'd
prefer not to, if it is possible. But any solution will be appreciated!

TPR.
--
Posted via http://www.ruby-....

1 Answer

Siep Korteling

9/19/2008 10:11:00 PM

0

Thomas B. wrote:
> Hello. I'd like to get the labels of the hard drives (partitions) on my
> machine from within a program. Is there any universal Ruby command to do
> it?
>
> I'm on Windows, so I guess I could use some WinAPI to do that but I'd
> prefer not to, if it is possible. But any solution will be appreciated!
>
> TPR.

For windows:

require 'ruby-wmi'

disks = WMI::Win32_LogicalDisk.find(:all, :conditions=>{:drivetype=>3})

disks.each do |disk|
puts "#{disk.deviceid} #{disk.volumename}"
end

# There is a lot more info in "disks"
puts "_______________________"

disks.each do |disk|
disk.properties_.each do |p|
puts "#{p.name}: #{disk[p.name]}" unless (disk[p.name]).nil?
end
end


hth,

Siep
--
Posted via http://www.ruby-....