Remove use of wmic#1981
Open
bwitt wants to merge 1 commit into
Open
Conversation
ekohl
reviewed
Jan 5, 2026
| ips = execute("wmic nicconfig where ipenabled=true GET IPAddress /format:list") | ||
|
|
||
| ip = '' | ||
| ips.each_line do |line| |
Member
There was a problem hiding this comment.
Thoughts about:
def get_ip
ips = execute('...')
ips.lines.map(&:strip).find { |line| Resolv::IPv4::Regex.match?(line) } || ''
end
Comment on lines
6
to
12
| groups = [] | ||
| result.stdout.each_line do |line| | ||
| groups << (line.match(/^Name=(.+)$/) or next)[1] | ||
| group = line.strip | ||
| next if group.empty? | ||
|
|
||
| groups << group | ||
| end |
Member
There was a problem hiding this comment.
How about:
groups = result.stdout.lines.map(&:strip).reject(&:empty?)This is also a repeated pattern in other files we can use to simplify the parsing.
| # IPAddress= | ||
| # IPAddress={"129.168.0.1"} | ||
| # IPAddress={"192.168.0.1","2001:db8:aaaa:bbbb:cccc:dddd:eeee:0001"} | ||
| ips = execute('powershell.exe -NoProfile -NonInteractive -Command "(Get-CimInstance Win32_NetworkAdapterConfiguration -Filter \'IPEnabled=True\' | ForEach-Object { $_.IPAddress })"') |
Member
There was a problem hiding this comment.
My understanding of the exec implementation is that it's the non-PowerShell implementation so can we really count on powershell.exe being present? If we can, is there any reason the user should even use this implementation or can we deprecate it altogether?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove use of
wmicfor Windows since it's deprecated or removed on newer versions.Fixes #1959