Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get IP Address on Windows 11 #25

Closed
erickriva opened this issue Feb 15, 2022 · 7 comments
Closed

Can't get IP Address on Windows 11 #25

erickriva opened this issue Feb 15, 2022 · 7 comments

Comments

@erickriva
Copy link

WMIC was removed from Windows 10/11.

image

There's no other way to implement this feature without WMIC, or with the new 'Powershell for WMI'?

@silverwind
Copy link
Owner

silverwind commented Feb 16, 2022

I guess it might be possible via route command unless that is deprecated too, but it certainly won't be as sophisticated as the wmic method was.

@silverwind
Copy link
Owner

silverwind commented Feb 16, 2022

Or maybe spawn powershell like https://stackoverflow.com/a/61219838/808699 and try to access WMI data via Get-CimInstance.

@erickriva
Copy link
Author

Well, route command works well here. Searched on Windows docs and this one is not deprecated. Hasn't tried yet.

But tried this command, and it works!
Get-CimInstance -Query "SELECT NextHop FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'"

I just don't know how to get only the specific value needed.

@silverwind
Copy link
Owner

silverwind commented Feb 16, 2022

Maybe some of the queries used on wmic still work. The wmic parsing is quite complex because in a situation with multiple default gateways, one needed to obtain the one with the highest overall metric, which was a sum of GatewayCostMetric and IPConnectionMetric, and there's different gateways for IPv4 and IPv6 of course.

@erickriva
Copy link
Author

Just sent #26
Working fine with powershell.
I did everything for WMIC part stay intact, but couldn't test. Please, test with it.
Hope it helps.

@erickriva
Copy link
Author

@silverwind please, give a look at it.

@silverwind
Copy link
Owner

Sorry, but I won't. See #27.

@erickriva erickriva closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants