是否可以在命令行中查看本地连接2是否已连接?
我使用一个简单的 *.bat 脚本在需要时自动更改 IP。该文件由以下内容组成:
"C:\Program Files\HMA! Pro VPN\bin\HMA! Pro VPN.exe" -changeip
sleep 30
问题是 HMA 有时需要 15 秒来更改 ip,有时需要 20 秒,有时超过 30 秒等。
我想摆脱 sleep 30
和相反,当 HMA 完成更改 IP 时退出脚本。有什么办法可以做到这一点吗?
如果有什么帮助的话。我发现如果我在 IP 更改时运行 ipconfig ,它会返回 Media State 。 。 。 。 。 。 。 。 。 。 。 :本地连接 2 的媒体已断开。我想知道是否有命令行命令来查明本地连接 2 是否已连接并以某种方式将其合并到脚本中就足够了。
任何帮助将不胜感激。
I have HideMyAss Pro VPN.
I use a simple *.bat script to automate changing of the IP when needed. The file consists of the following:
"C:\Program Files\HMA! Pro VPN\bin\HMA! Pro VPN.exe" -changeip
sleep 30
The problem is that HMA sometimes takes 15 seconds to change ip, sometimes 20 seconds, sometimes more than 30 seconds, etc.
I'd like to get rid of sleep 30
and instead exit the script when HMA finishes changing IP. Is there any way to do this?
If it's any help. I found out that if I run ipconfig
while the IP change takes place, it returns Media State . . . . . . . . . . . : Media disconnected
for Local Area Connection 2. I suppose it would suffice to know if there's a command line command to find out if Local Area Connection 2 is connected and somehow incorporate that into the script.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有简单的方法来检查网络适配器的状态。您可以解析 ipconfig 的输出(更准确),但它很复杂。
这应该可以解决问题。
There is no simple way to check status of the network adapter. You can parse output of
ipconfig
(which is more accurately) but it's complicated.This should do the trick.
您可以使用
netsh
检查网卡的连接状态。只需使用即可在 %state% 变量中捕获连接状态。
You can use
netsh
to check connection state of network card. Just useand you will have the connection state captured in %state% variable.
你的问题帮助了我,我正在寻找同样的事情“改变IP”我知道总是有延迟,但为什么不让它1分钟。因为这总是有效的,如果它有效的话,等待更长的时间并不重要。
Your question helped me i was seeking for the same thing "to change ip " i know there is always a delay but why not make it 1 min . As that would always work and waiting a bit longer wont matter if it works rite.