Skip to content

Instantly share code, notes, and snippets.

@jasonlyles
Created September 17, 2009 19:11
Show Gist options
  • Save jasonlyles/188663 to your computer and use it in GitHub Desktop.
Save jasonlyles/188663 to your computer and use it in GitHub Desktop.
require 'win32ole'
#PUTS-ing Route table
ole = WIN32OLE.connect("winmgmts://")
query = "select * from Win32_IP4RouteTable"
puts "Network Address\t\tNetmask\t\tGateway Address\t\tMetric"
ole.ExecQuery(query).each do |route|
puts "#{route.Destination}\t\t#{route.Mask}\t\t#{route.NextHop}\t\t#{route.Metric1}"
end
#PUTS-ing ipconfig type stuff
query = "select * from Win32_NetworkAdapterConfiguration where IPEnabled = True"
ole.ExecQuery(query).each do |nic|
puts nic.IpAddress
puts nic.IpSubnet
puts nic.DefaultIPGateway
puts nic.DNSHostName
end
#PUTS-ing Registry entries
obj = WIN32OLE.new('WScript.Shell')
path = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Path\\To\\Where\\U\\Want\\2\\B\\"
ubd_key = "UserBaseDir"
sql_connect_key = "SQLConnectString"
crlbd_key = "CRLBaseDir"
a = [ubd_key, sql_connect_key, crlbd_key]
a.each do |key|
puts obj.RegRead("#{path}#{key}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment