Skip to content

Instantly share code, notes, and snippets.

@bil-bas
Last active December 12, 2015 04:49
Show Gist options
  • Save bil-bas/4717164 to your computer and use it in GitHub Desktop.
Save bil-bas/4717164 to your computer and use it in GitHub Desktop.
# i want to keep ip and gw, but i want to avoid repeating from "adapters.each" to netconnectionsid.each in both of them. lambdas?
general do |netconnectionid|
Nic::IPConfig.enablestatic(netconnectionid,
:ip => myconfig[:ipaddress],
:mask => myconfig[:subnetmask])
end
general do |netconnectionid|
Nic::IPConfig.setgateways(netconnectionid,
:defaultgw => myconfig[:defaultgw],
:gwcostmetric => myconfig[:gwcostmetric])
end
def general
raise "needs a block" unless block_given?
adapters.each { |adapter|
if adapter.deviceid
nicid=adapter.deviceid
netconnectionids=Nic::IPConfig.wmi_exec_assoc(my_wmi, nicid)
netconnectionids.each { |netconnectionid| yield netconnectionid }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment