wmic /failfast does nothing

邮差的信 提交于 2019-12-24 15:05:09

问题


    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

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?

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

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

回答1:


Read about /FAILFAST switch:

Whether or not the /NODE computers are checked before trying to execute the WMIC commands against them. When FAILFAST is ON, WMIC pings the computers in the /NODE switch before sending WMIC commands to them. If they do not respond to the ping, the WMIC commands are not executed for them.

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"


来源:https://stackoverflow.com/questions/34307084/wmic-failfast-does-nothing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!