Hi,
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.
dave
···
--
Posted via http://www.ruby-forum.com/.
Please see:
require 'win32ole'
HKLM = 0x80000002
computer = "."
reg =
WIN32OLE.connect("winmgmts://#{computer}/root/default:StdRegProv")
in_params = reg.Methods_("EnumKey").inParameters.SpawnInstance_()
in_params["hDefKey"] = HKLM
in_params["sSubKeyName"] =
'Software\Microsoft\Windows\Currentversion\Uninstall'
out_params = reg.ExecMethod_("EnumKey",in_params)
out_params.sNames.each { |key_names| puts key_names }
David dave wrote:
···
Hi,
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.
dave
--
Posted via http://www.ruby-forum.com/\.
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
···
--
Posted via http://www.ruby-forum.com/.
Try this:
require 'win32ole'
HKLM = 0x80000002
computer = "machine1"
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc =
locator.ConnectServer(computer,"root\\default","user","password",nil,nil,nil,nil)
reg = svc.Get("StdRegProv")
in_params = reg.Methods_("EnumKey").inParameters.SpawnInstance_()
in_params["hDefKey"] = HKLM
in_params["sSubKeyName"] =
'Software\Microsoft\Windows\Currentversion\Uninstall'
out_params = reg.ExecMethod_("EnumKey",in_params)
out_params.sNames.each { |key_name| puts key_name }
David dave wrote:
···
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
--
Posted via http://www.ruby-forum.com/\.