從其他的問題,我已經在這裏找到了格式,我想這會工作怎樣才能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