如何把wmic nic get NetConnectionID加入变量能不能只把正在使用的NetConnectionID存储到名为var的变量中
在Windows命令提示符中,可以使用以下命令将正在使用的网卡连接ID存储到名为“var”的变量中:
for /f "skip=1 tokens=1 delims=:" %a in ('wmic nic where "NetConnectionStatus=2" get NetConnectionID /value') do @set var=%a
如果要在批处理脚本中使用,需要将“%a”改为“%%a”。如下所示:
@echo off
for /f "skip=1 tokens=1 delims=:" %%a in ('wmic nic where "NetConnectionStatus=2" get NetConnectionID /value') do set var=%%a
echo %var%
这将输出正在使用的网卡连接ID。
原文地址: https://www.cveoy.top/t/topic/b3uK 著作权归作者所有。请勿转载和采集!