bmedward
6/8/2006 5:08:00 PM
I am running ruby 1.8.4 (2005-12-24) [i386-mswin32] and am attempting
to re-write some maintaince scripts from VBScript to Ruby. In doing
so, I have run into a hangup with how Ruby is treating an ExecQuery
statment - whenever I include a 'Path' in the query, I get an empty
collection. Is there a known problem that I am encountering here, or
perhaps a better way that I can utilize this parameter?
Here is an example that fails for me.
1. require 'win32ole'
2. myComputer = "."
3. strSQLQuery = " Select * from CIM_DataFile WHERE Drive = 'C:' AND
Path = '\\' "
4. objWMIService =
WIN32OLE.connect("winmgmts:{impersonationLevel=impersonate}!//#{myComputer}/root/cimv2")
5. colFiles = objWMIService.ExecQuery(strSQLQuery)
6.
7. colFiles.each do |file|
8. puts file.Drive + file.Path + file.FileName + "." +
file.Extension
9. end
If I replace the query with:
"Select * from CIM_DataFile WHERE Drive = 'C:' AND Extension = 'rb' "
All works as expected. Also note that the 'Path' attribute can be read
without error.