for /f "tokens=*" %%a in (ip.txt) do (
wmic /FAILFAST:ON /node:%%a /user: /password: computersystem get Name, domain, Manufacturer, Model, NumberofProcessors, PrimaryOwnerName,Username, Roles, totalphysicalmemory /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: cpu get Name, Caption, MaxClockSpeed, DeviceID, status /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: path Win32_VideoController get Name, status, DeviceID /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: os get Version, Caption, CountryCode, CSName, Description, InstallDate, SerialNumber, ServicePackMajorVersion, WindowsDirectory /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: csproduct get identifyingnumber /format:list
) >%%a.txt
这是我的代码,它可以像它应该的那样工作,但/FAILFAST:ON
如果等待10-20秒它会跳到下一个,我需要它更快地扫描大型系统,任何人都有任何想法?
我可以使用if命令ping 1包,如果没有响应则转到next吗?
感谢JosefZ:
for /f "tokens=*" %%a in (ip.txt) do (
set "_ready="
for /F %%G in ('ping -4 -n 1 %%a^|find "TTL="') do set "_ready=%%G"
if defined _ready (
rem your `WMIC /FAILFAST:OFF /node:%%a …`
wmic /node:%%a /user: /password: computersystem get Name, domain, Manufacturer, Model, NumberofProcessors, PrimaryOwnerName,Username, Roles, totalphysicalmemory /format:list
wmic /node:%%a /user: /password: cpu get Name, Caption, MaxClockSpeed, DeviceID, status /format:list
wmic /node:%%a /user: /password: path Win32_VideoController get Name, status, DeviceID /format:list
wmic /node:%%a /user: /password: os get Version, Caption, CountryCode, CSName, Description, InstallDate, SerialNumber, ServicePackMajorVersion, WindowsDirectory /format:list
wmic /node:%%a /user: /password: csproduct get identifyingnumber /format:list
)>"%%a.txt"
)
答案 0 :(得分:1)
在尝试之前是否检查
/NODE
台计算机 对它们执行WMIC
命令。当FAILFAST
为ON
时, 在发送WMIC
之前/NODE
点击WMIC
交换机中的计算机 对他们的命令。如果他们没有响应ping,WMIC
不会为它们执行命令。
每个服务器的一个日志文件:
for /f "tokens=*" %%a in (ip.txt) do (
set "_ready="
for /F %%G in ('ping -4 -n 1 %%a^|find "TTL="') do set "_ready=%%G"
if defined _ready (
rem your `WMIC /FAILFAST:OFF /node:%%a …` commands here
)>"%%a.txt"
)
或所有服务器的唯一日志文件:
for /f "tokens=*" %%a in (ip.txt) do (
set "_ready="
for /F %%G in ('ping -4 -n 1 %%a^|find "TTL="') do set "_ready=%%G"
if defined _ready (
rem your `WMIC /FAILFAST:OFF /node:%%a …` commands here
)
)>"logservers.txt"