Board logo

标题: [其他] 请教检测系统sp版本的批处理如何优化? [打印本页]

作者: quake_wu    时间: 2009-11-20 14:04     标题: 请教检测系统sp版本的批处理如何优化?

写了一个扫描局域网哪些电脑是sp1,哪些电脑是sp2的检测脚本
请帮忙看看有哪些纰漏或者需要改进的地方
  1. @echo off
  2. del %temp%\GetHostname.txt 2>nul
  3. Echo Now is Scanning 192.168.0.0/24
  4. for /l %%i in (1,1,254) do ping -a -n 1 192.168.0.%%i&&ping -a -n 1 192.168.0.%%i|find "Pinging" >>%temp%\GetHostname.txt
  5. Echo Now is Scanning 192.168.1..0/24
  6. for /l %%i in (1,1,254) do ping -a -n 1 192.168.1.%%i&&ping -a -n 1 192.168.1.%%i|find "Pinging" >>%temp%\GetHostname.txt
  7. Echo Now is Scanning 192.168.2.0/24
  8. for /l %%i in (1,1,254) do ping -a -n 1 192.168.2.%%i&&ping -a -n 1 192.168.2.%%i|find "Pinging" >>%temp%\GetHostname.txt
  9. Echo.>>c:\ok.txt&Echo Scan time begin from %date%/%time% >>c:\ok.txt
  10. Echo.>>c:\ok.txt&Echo These Servers are Service pack 1 >>c:\ok.txt
  11. for /f "tokens=2 delims= " %%i in (%temp%\GetHostname.txt) do reg query "\\%%i\HKLM\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION" /v csdversion |find "Service Pack 1" && Echo %%i >>c:\ok.txt
  12. Echo ------------------------------------------------>>c:\ok.txt
  13. Echo These Servers are Service pack 2 >>c:\ok.txt
  14. Echo.>>c:\ok.txt
  15. for /f "tokens=2 delims= " %%i in (%temp%\GetHostname.txt) do reg query "\\%%i\HKLM\SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION" /v csdversion |find "Service Pack 2" && Echo %%i >>c:\ok.txt
  16. Echo.>>c:\ok.txt&Echo Scan time End from %date%/%time% >>c:\ok.txt
  17. Echo The result Will be saved at c:\ok.txt
  18. Echo Press any key to Exit
  19. pause>nul
复制代码

[ 本帖最后由 quake_wu 于 2009-11-20 15:19 编辑 ]
作者: Batcher    时间: 2009-11-20 19:03

参考:http://bbs.bathome.net/viewthread.php?tid=4482#pid28940




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2