健康一贴灵,专注医药行业管理信息化

判断网络是否通断,服务是否存在的BAT批处理(转)

@echo off
title DDI自检程序
echo.
echo.
ping -n 2 www.baidu.com>%temp%\1.ping & ping -n 2 www.baidu.com>>%temp%\1.ping
if %errorlevel%==0 (echo     √ 外网正常) else (echo     × 外网不通)
echo.
::ping -n 2 192.168.1.1>%temp%\2.ping
::findstr "TTL" %temp%\2.ping>nul
::if %errorlevel%==0 (echo     √ 网关正常) else (echo     × 网关不通)
::echo.
::ping -n 2 192.168.1.2>%temp%\3.ping
::findstr "TTL" %temp%\3.ping>nul
::if %errorlevel%==0 (echo     √ 内网正常) else (echo     × 内网不通)
::echo.
ping -n 2 127.0.0.1>%temp%\4.ping
findstr "TTL" %temp%\4.ping>nul
if %errorlevel%==0 (echo     √ TCP/IP协议正常) else (echo     × TCP/IP协议异常)
if exist %temp%\*.ping del %temp%\*.ping
echo.
set checked=0

if exist "%windir%\Microsoft.NET\Framework\v4.0*" set checked=1
if exist "%windir%\Microsoft.NET\Framework\v4.5*" set checked=1
if exist "%windir%\Microsoft.NET\Framework\v4.7*" set checked=1

if %checked% EQU 1 (echo     √ .NET Framework已安装) else (echo     × .NET Framework4.0未安装)

echo.
sc query DDIClientAppService >nul
if %ErrorLevel% EQU 0 (echo     √ 服务存在) else (echo     × 服务不存在)

echo.
sc query "DDIClientAppService" |findstr /i "RUNNING" >nul &&echo     √ 服务正在运行 ||echo     × 服务未运行



echo.
echo.
pause

  

posted @ 2025-10-17 10:56  一贴灵  阅读(7)  评论(0)    收藏  举报
学以致用,效率第一