本文介绍了wmic/failfast什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    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

这是我的代码,它的工作原理与它应该做的一样,但是如果等待10到20秒,它会跳到下一个/FAILFAST:ON ,我需要它更快地进行大尺寸扫描系统,有人有想法吗?

This is my code and it works like it should do, but the /FAILFAST:ON it does skip to next if you wait 10-20 sec, I need it to go faster to scan large systems, anybody got any ideas?

我可以使用if命令对1个数据包执行ping操作,如果无响应则转到下一个命令吗?

Could I use an if command that pings with 1 packet and goes to next if no response ?

感谢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"
)

推荐答案

了解有关 /FAILFAST 开关:

Read about /FAILFAST switch:

每个服务器一个日志文件:

One log file for each server:

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"
)

或所有服务器的唯一日志文件:

or the only log file for all servers:

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"

这篇关于wmic/failfast什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-20 19:49