multipass icon indicating copy to clipboard operation
multipass copied to clipboard

@mconner, how to get the %IPADDRESS%

Open lqllife opened this issue 3 years ago • 0 comments

@mconner, Thanks for your reply, I have a question when getting the %IPADDRESS%, hope to get your reply soon.

reference#567

When I put the code in a cmd file and run it , it can't set the address successful.

PS C:\Users\lql\Desktop> .\a.cmd

C:\Users\lql\Desktop>SET count=1

C:\Users\lql\Desktop>FOR /F "tokens=* USEBACKQ" %F IN (`wmic nicconfig where "caption like '%Hyper-V Virtual Ethernet Adapter%'" get ipaddress,caption,IPSubnet`) DO (
SET LINE!count!=%F
 set /a count=!count!+1
)
没有可用实例。

C:\Users\lql\Desktop>(
  T LINE!count!=
 set /a count=!count!+1
)
运算符不存在。

C:\Users\lql\Desktop>(
  T LINE!count!=
 set /a count=!count!+1
)
运算符不存在。

C:\Users\lql\Desktop>rem echo Header:

C:\Users\lql\Desktop>echo Data:
Data:

C:\Users\lql\Desktop>rem split by " as delimiter, get 2nd part:

C:\Users\lql\Desktop>for /F tokens=2 delims=" %G in ("") DO (SET IPADDRESS=%G )

here is my ipconfig

PS C:\Users\lql\Desktop> ipconfig

Windows IP 配置


以太网适配器 以太网:

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . : fe80::c849:ee6b:4f58:d31a%11
   IPv4 地址 . . . . . . . . . . . . : 192.168.124.32
   子网掩码  . . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . : 192.168.124.1

无线局域网适配器 本地连接* 1:

   媒体状态  . . . . . . . . . . . . : 媒体已断开连接
   连接特定的 DNS 后缀 . . . . . . . :

无线局域网适配器 本地连接* 2:

   媒体状态  . . . . . . . . . . . . : 媒体已断开连接
   连接特定的 DNS 后缀 . . . . . . . :

无线局域网适配器 WLAN:

   媒体状态  . . . . . . . . . . . . : 媒体已断开连接
   连接特定的 DNS 后缀 . . . . . . . :

以太网适配器 蓝牙网络连接:

   媒体状态  . . . . . . . . . . . . : 媒体已断开连接
   连接特定的 DNS 后缀 . . . . . . . :

隧道适配器 Teredo Tunneling Pseudo-Interface:

   连接特定的 DNS 后缀 . . . . . . . :
   IPv6 地址 . . . . . . . . . . . . : 2001:0:2851:b9f0:2022:cf4c:dbdc:e247
   本地链接 IPv6 地址. . . . . . . . : fe80::2022:cf4c:dbdc:e247%15
   默认网关. . . . . . . . . . . . . : ::

以太网适配器 vEthernet (Default Switch):

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . : fe80::a874:183f:83b:b5ef%23
   IPv4 地址 . . . . . . . . . . . . : 172.27.240.1
   子网掩码  . . . . . . . . . . . . : 255.255.240.0
   默认网关. . . . . . . . . . . . . :

以太网适配器 vEthernet (WSL):

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . : fe80::b0a3:5eb6:f4d2:218b%49
   IPv4 地址 . . . . . . . . . . . . : 172.25.224.1
   子网掩码  . . . . . . . . . . . . : 255.255.240.0
   默认网关. . . . . . . . . . . . . :

the ipv4 of vEthernet (Default Switch) is the right value of %IPADDRESS%?

my route lists

PS C:\Users\lql\Desktop> route PRINT
===========================================================================
接口列表
 11...2c 16 db a7 f9 70 ......Realtek USB GbE Family Controller
  6...fc 44 82 d2 87 92 ......Microsoft Wi-Fi Direct Virtual Adapter
  5...fe 44 82 d2 87 91 ......Microsoft Wi-Fi Direct Virtual Adapter #2
 14...fc 44 82 d2 87 91 ......Intel(R) Wi-Fi 6 AX201 160MHz
 10...fc 44 82 d2 87 95 ......Bluetooth Device (Personal Area Network)
  1...........................Software Loopback Interface 1
 15...00 00 00 00 00 00 00 e0 Microsoft Teredo Tunneling Adapter
 23...00 15 5d 80 a9 8d ......Hyper-V Virtual Ethernet Adapter
 49...00 15 5d a9 ef 27 ......Hyper-V Virtual Ethernet Adapter #2
===========================================================================

IPv4 路由表
===========================================================================
活动路由:
网络目标        网络掩码          网关       接口   跃点数
          0.0.0.0          0.0.0.0    192.168.124.1   192.168.124.32     25
        127.0.0.0        255.0.0.0            在链路上         127.0.0.1    331
        127.0.0.1  255.255.255.255            在链路上         127.0.0.1    331
  127.255.255.255  255.255.255.255            在链路上         127.0.0.1    331
     172.25.224.0    255.255.240.0            在链路上      172.25.224.1   5256
     172.25.224.1  255.255.255.255            在链路上      172.25.224.1   5256
   172.25.239.255  255.255.255.255            在链路上      172.25.224.1   5256
     172.27.240.0    255.255.240.0            在链路上      172.27.240.1   5256
     172.27.240.1  255.255.255.255            在链路上      172.27.240.1   5256
   172.27.255.255  255.255.255.255            在链路上      172.27.240.1   5256
    192.168.124.0    255.255.255.0            在链路上    192.168.124.32    281
   192.168.124.32  255.255.255.255            在链路上    192.168.124.32    281
  192.168.124.255  255.255.255.255            在链路上    192.168.124.32    281
        224.0.0.0        240.0.0.0            在链路上         127.0.0.1    331
        224.0.0.0        240.0.0.0            在链路上      172.27.240.1   5256
        224.0.0.0        240.0.0.0            在链路上      172.25.224.1   5256
        224.0.0.0        240.0.0.0            在链路上    192.168.124.32    281
  255.255.255.255  255.255.255.255            在链路上         127.0.0.1    331
  255.255.255.255  255.255.255.255            在链路上      172.27.240.1   5256
  255.255.255.255  255.255.255.255            在链路上      172.25.224.1   5256
  255.255.255.255  255.255.255.255            在链路上    192.168.124.32    281
===========================================================================
永久路由:
  无

IPv6 路由表
===========================================================================
活动路由:
 接口跃点数网络目标                网关
 15    331 ::/0                     在链路上
  1    331 ::1/128                  在链路上
 15    331 2001::/32                在链路上
 15    331 2001:0:2851:b9f0:2022:cf4c:dbdc:e247/128
                                    在链路上
 23   5256 fe80::/64                在链路上
 49   5256 fe80::/64                在链路上
 11    281 fe80::/64                在链路上
 15    331 fe80::/64                在链路上
 15    331 fe80::2022:cf4c:dbdc:e247/128
                                    在链路上
 23   5256 fe80::a874:183f:83b:b5ef/128
                                    在链路上
 49   5256 fe80::b0a3:5eb6:f4d2:218b/128
                                    在链路上
 11    281 fe80::c849:ee6b:4f58:d31a/128
                                    在链路上
  1    331 ff00::/8                 在链路上
 23   5256 ff00::/8                 在链路上
 49   5256 ff00::/8                 在链路上
 11    281 ff00::/8                 在链路上
 15    331 ff00::/8                 在链路上
===========================================================================
永久路由:
  无

lqllife avatar May 16 '22 03:05 lqllife