Skip to content

Conversation

@awithersdd
Copy link

No description provided.

@jmccann
Copy link

jmccann commented Mar 27, 2015

Hey guys. I'd love this as well. Here's a use case I'm running into:

I try renaming a network interface through the NetworkAdapter returned and instead blank it out:

[89] pry(main)> a = WMI::Win32_NetworkAdapter.find(:all, :conditions => { :net_connection_id => 'test2' } ).first
=> #<RubyWMI::Win32_NetworkAdapter:Intel(R) PRO/1000 MT Desktop Adapter>
[90] pry(main)> a.NetConnectionID
=> "test2"
[91] pry(main)> a.NetConnectionID = 'test3'
=> "test3"
[92] pry(main)> a.NetConnectionID
=> nil
[93] pry(main)> w = a.instance_variable_get(:@win32ole_object)
=> #<WIN32OLE:0x34568b8>
[94] pry(main)> w.NetConnectionID
=> nil

Now I get the instance variable from the NetworkAdapter returned and am able to properly rename it:

[95] pry(main)> a = WMI::Win32_NetworkAdapter.find(:all, :conditions => { :net_connection_id => 'test2' } ).first
=> #<RubyWMI::Win32_NetworkAdapter:Intel(R) PRO/1000 MT Desktop Adapter>
[96] pry(main)> w = a.instance_variable_get(:@win32ole_object)
=> #<WIN32OLE:0x3535f80>
[97] pry(main)> w.NetConnectionID
=> "test2"
[98] pry(main)> w.NetConnectionID = 'test3'
=> "test3"
[99] pry(main)> w.NetConnectionID
=> "test3"
[100] pry(main)> a.Put_
=> #<WIN32OLE:0x3393858>
[101] pry(main)> w.NetConnectionID
=> "test3"
[102] pry(main)> a.NetConnectionID
=> "test3"
[103] pry(main)>

Now I monkeypatch this edit in and can also rename now through NetworkAdapter as expected:

[105] pry(main)> a = WMI::Win32_NetworkAdapter.find(:all, :conditions => { :net_connection_id => 'test3' } ).first
=> #<RubyWMI::Win32_NetworkAdapter:Intel(R) PRO/1000 MT Desktop Adapter>
[106] pry(main)> a.NetConnectionID
=> "test3"
[107] pry(main)> a.NetConnectionID = 'test4'
=> "test4"
[108] pry(main)> a.NetConnectionID
=> "test4"
[109] pry(main)> a.Put_
=> #<WIN32OLE:0x35ead90>

@djberg96
Copy link

Any chance of merging this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants