批处理文件挂起

时间:2014-03-11 16:26:51

标签: windows batch-file csv

我正在尝试获取批处理文件以将某些数据输出到CSV文件。我在命令行中完美地运行了该命令,但在将其复制到批处理文件时却没有。运行时,它只会挂起并重复CSV文件。

这是批处理脚本:

getmac /fo csv /nh >> C:\Users\Username\Desktop\test.csv

我要做的是在我们拥有的所有新实验室计算机上运行此脚本,并生成一个可用于在DHCP服务器中保留IP的mac地址列表。

理想情况下,我也想要计算机名称,但这并不是真正需要的。 我正在运行Windows 7 Professional。

1 个答案:

答案 0 :(得分:0)

wmic /node:@"%userprofile%\desktop\computername.txt" /failfast:on nicconfig where ipenabled=true get caption,macaddress,ipaddress /format:csv

列出节点(计算机名称),IPAddress,MACAddress和NIC的描述。

要生成已打开的计算机列表,

for /f "skip=3 delims=\" %A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %A >> "%userprofile%\desktop\computername.txt"

请参阅wmic /?wmic nicconfig /?wmic nicconfig get /?wmic nicconfig set /?wmic nicconfig call /?wmic /format /?wmic /node /?,{{1} },wmic /failfast /?for /?