如果只想把正在使用的 NetConnectionID 存储到名为 'var' 的变量中,可以使用以下命令:

for /F "skip=1 tokens=1 delims=:" %a in ('wmic nic where "NetConnectionStatus=2" get NetConnectionID /value') do set "var=%a"

注意要在变量名前加上双引号,以防止变量值中包含空格或特殊字符导致命令解析错误。

如何将 wmic nic get NetConnectionID 结果存储到变量中

原文地址: https://www.cveoy.top/t/topic/jC1V 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录