require 'win32ole' require 'socket' host = Socket.gethostname cs = "winmgmts://#{host}/root/cimv2" begin wmi = WIN32OLE.connect(cs) rescue WIN32OLERuntimeError => e raise "Unsupported Windows Version." else query = "select * from Win32_LogicalDisk" hd = wmi.InstancesOf("Win32_OperatingSystem") hd.each { |f| puts f.FreeSpace } end