从其他的问题,我已经在这里找到了格式,我想这会工作怎样才能getmac输出成批处理文件的变量,并保持
SET LF=^
SET output=
SET getmac_cmd=getmac /v /fo list
FOR /F "USEBACKQ tokens=*" %%F in (`!getmac_cmd!`) DO (
set output=!output!!LF!%%F
)
ECHO !output!
该命令的输出直接看起来像
Connection Name: Local Area Connection
Network Adapter: Intel Something
Physical Address: 00-00-00-00-00-00
Transport Name: Media disconnected
Connection Name: Bluetooth Network Connection
Network Adapter: Bluetooth Something
Physical Address: 00-00-00-00-00-00
Transport Name: Media disconnected
但是,当通过批处理脚本运行,我得到
Connection Name: Local Area Connection
Network Adapter: Intel Something
Physical Address: 00-00-00-00-00-00
Transport Name: Media disconnected
Connection Name: Bluetooth Network Connection
Network Adapter: Bluetooth Something
Physical Address: 00-00-00-00-00-00
Transport Name: Media disconnected
任何线索,我可以改变它去保留段之间的实际空白行?
为什么你需要在一个变量整个文本? – aschipfl