Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
WIN32OLE heartburn
David dave
3/27/2006 4:32:00 PM
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-...
.
3 Answers
jelenicm
3/27/2006 7:49:00 PM
0
Please see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/writing_wmi_scripts_in_j...
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-...
.
David dave
3/27/2006 9:56:00 PM
0
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-...
.
jelenicm
3/28/2006 2:35:00 PM
0
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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
WIN32OLE heartburn
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