After using WIN32OLE, I have been having trouble using WMI to create a
objWMIService object.
1)
locator = WIN32OLE.new(â??WbemScripting.SWbemLocatorâ?)
mgmt = locator.ConnectServer computer, ‘/root/default:StdRegProv’,
login, password
2)
mgmt =
WIN32OLE.connect(â??winmgmts:\\#{computer}/root/default:StdRegProvâ?)
I think these two methods should be equivalent objects, however the
first method is missing several internal structures like EnumKey. The
second method does contain EnumKey, but I can not login with an
impersonation. If anyone had any ideas I would appreciate them.
Thank you for the reply. Is there another way to reach a remote
registry and use impersonation? I am not sure how to login under a
different user given your example.
dave
Had some trouble getting the above suggestions to work (I’m currently
using Ruby 1.9.2). I kept messing around and finally came up with the
following that seems to do great. It works for the local machine as
well as any remote machine for which the current user context also has
sufficient rights. It’s got an example for a key enumeration, value
enumeration, and a value retrieval:
require ‘win32ole’
class WIN32OLE
def list_ole_methods
method_names = ole_methods.collect {|m| m.name}
# puts method_names.sort.uniq
return method_names.sort.uniq
end
end