【运维知识】BAT处理 延迟启动程序 临时解决网络IP获取慢导致的网络连接失败
某些软件程序在随操作系统自起过程中容易出现网络连接失败,导致软件崩溃。用户体验效果不佳。
我们可以使用BAT处理 来临时解决问题。
@echo off
title "Li启动程序v1.0"
::最小化窗口运行
if "%1"=="h" goto begin
start mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",2)(window.close)&&exit
:begin
::配置地址
SET str_ip=135.32.114.117
SET str_path="C:\Program Files\FileZilla FTP Client\filezilla.exe"
::获取执行程序完整名称
set "filepath="%str_path: =%
for /f %%a in ("%filepath%") do set "filename=%%~nxa"
::防止重复运行
tasklist |findstr %filename%
taskkill /im %filename%
::设置最大检测次数
set /a i=0,max=5
:loop
set /a i+=1
if %i% gtr %max% ( echo 超出检测次数 && goto :end)
echo %i%.检测网络状态中...
ping %str_ip% -n 3 | find /i "TTL" || goto :loop
echo 检测网络状态[已连接]
if exist %str_path% (
echo 启动程序
start "" %str_path%
) else (
echo Error:指定文件不存在
echo %str_path%
)
:end
@pause
exit
::start "form_title" "C:\Program Files\FileZilla FTP Client\filezilla.exe"

浙公网安备 33010602011771号