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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
How to read drive label
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password