Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1540

Help: Rainmeter Skins • Re: Show all active IPv4 regardless of adapter name / index

$
0
0
Hi all,

Having a bit of a problem getting my head around this one. I'm having to revisit a skin I made some time ago and have noted a change in the way that the SysInfo Measure works which is now giving me some grief.

Ideally what I want to happen is that all active IP v4 addresses are shown (or maximum 4 or 5) which would be fine if this was for one specific device but the skin is deployed to a large number of devices with varying configurations. So, regardless of hardware and interface indexes, I need to show the IPv4 addresses. Previously I'd been just trying all indexes from 0-9 and hiding them if they're not present. I noted the other day that VPN addresses were not showing or we were getting duplicated entries. I note that this is because using "SysInfoData=0 for IP_ADDRESS now translates to "Best" and that my active VPN network index was 24 so was being ignored by the measures.

So... How can I get Rainmeter to effectively loop through active network adapters and display IPv4 information without knowing the names of the installed adapters or the index numbers?

Thanks in advance...
That scheme can't ever really work. There are dozens and dozens of adapters in a normal Windows machine, and the index numbers change all the time, so just checking indexes 0-9 can't work unless you are really lucky. My machines typically have 50+ adapters, and the active adapter index is usually something >20, for example.

Secondly, your question "How can I get Rainmeter to effectively loop through active network adapters..." contains a key point. Rainmeter doesn't "loop". You need to either build 50+ measures to try every possible adapter on your system (however many you have), or come up with a better approach.

I'd suggest something like this. First, use a RunCommand measure to fire off a PowerShell command that can fetch all the IPv4 addresses on the machine. Second, Use a WebParser measure (with a regex that uses lookaheads to handle multiple results) to read this resulting PowerShell output to parse out all the IP address data (for an many rows as you want/need).

This way, you don't need to know adapter names or indexes, and you won't need dozens and dozens of measures pinging useless virtual adapters.

To get you started, here is a PS command that will get you all the IPv4 addresses on your machine. You only really need the first column, but I added the others so you can see the indexes and adapter names in case you are curious.

Code:

Get-NetIPAddress | Where-Object { $_.AddressFamily -eq 'IPv4' } | Where-Object { $_.IPAddress -ne '127.0.0.1' } | Sort-Object -Property InterfaceIndex | Format-Table -Property IPAddress, InterfaceIndex, InterfaceAlias

Statistics: Posted by SilverAzide — Today, 12:46 pm



Viewing all articles
Browse latest Browse all 1540

Trending Articles