本帖最后由 neorobin 于 2012-6-2 11:00 编辑
- @echo off & setlocal enabledelayedexpansion
- set "Ports=8001 8002"
- for %%a in (%Ports% Any) do set "found%%a=0"
- set "foundAll=1"
- for /f "tokens=3,5 delims=: " %%a in ('netstat -an') do (
- set /a "found%%a=1,found%%b=1"
- )
-
- for %%a in (%Ports%) do set /a "foundAll&=found%%a, foundAny|=found%%a"
- if "!foundAll!"=="1" (echo,找到全部端口) else (
- for %%a in (%Ports%) do if "!found%%a!"=="1" (echo,找到端口 %%a) else (echo,未找到端口 %%a)
- if "!foundAny!"=="0" (echo,未找到任何端口)
- )
- pause
复制代码
|