带进度条的自动运行系统补丁包程序的批处理

功能:自动判断当前系统,并逐个运行当前文件夹里面的系统补丁包程序。

@echo off
:: hnfeng 20120416
:: ◆自动运行文件夹里面所有系统补丁程序并显示总进度及正在安装的程序名◆
:: ================================
cd /d "%~dp0"&color 3E&mode con lines=15 &title 补丁包批处理安装程序〔hnfeng〕
ver | find "6.1" > NUL && (set XT=Windows7&set CX=Windows6.1-KB*.msu&set CS=/quiet /norestart&goto TOP)
ver | find "5.1" > NUL && (set XT=WindowsXP&set CX=WindowsXP-KB*.exe&set CS=/quiet /norestart /nobackup&goto TOP)
ver | find "5.0" > NUL && (set XT=Windows2000&set CX=Windows2000-KB*.exe&set CS=/quiet /norestart /nobackup&goto TOP)
ver | find "5.2" > NUL && (set XT=Windows2003&set CX=WindowsServer2003-KB*.exe&set CS=/quiet /norestart /nobackup&goto TOP)
ver | find "6.0" > NUL && (set XT=WindowsVista&set CX=Windows6.0-KB*.msu&set CS=/quiet /norestart&goto TOP)
:: ================================
:TOP
set title=%XT% 补丁包批处理安装程序〔hnfeng〕
title %title%
set work=0&set n=0&set mo=0&set number=0&set hotfix=
if not exist %CX% echo.&echo.&echo 没找到补丁程序,按任意键退出 ...&echo.&echo.&echo (该批处理应该在系统补丁程序所在文件夹里运行.)&pause>nul&exit
set k=▏&set kn=0
:Kong
if %kn% LSS 33 (set k=%k% &set /a kn=%kn%+1&goto Kong)
for /F %%s in ('dir /b /a-d %CX% ^| find /v /c ""') do set all=%%s
for /F %%i in ('dir /b /a-d /OD %CX%') do (set hotfix=%%i&call :show)
set hotfix=&call :show
goto end

:show
:check
if %number% GTR %mo% set num=%num%█&set /a mo=%mo%+1&set k=%k:~0,-1%&goto check

cls&echo.&echo.
if "%hotfix%"=="" (echo %title% ) else (echo 正在安装:%hotfix% ...)
echo 进度: %n% / %all%
echo.&echo 已经完成 %work% %%%
echo ┌──────────────────────────────────┐
echo │%num%%k%│&echo │%num%%k%│&echo │%num%%k%│
echo └──────────────────────────────────┘
echo.
if not "%hotfix%"=="" echo hnfeng.2012.4
if %work%==100 goto :EOF
::ping 127.1 -n 2 >nul
%hotfix% %CS%
set /a n=%n%+1
set /a work=(%n%)*100/(%all%)
set /a number=%work%/3
set /a number=%number%+1
goto :EOF

:end
echo 运行完成,请按任意键退出... (建议重新启动系统)
pause>nul&exit

如果需要打Office补丁的进度条代码,只需把这几行删掉

ver | find "6.1" > NUL && (set XT=Windows7&set CX=Windows6.1-KB*.msu&set CS=/quiet /norestart&goto TOP)
ver | find "5.1" > NUL && (set XT=WindowsXP&set CX=WindowsXP-KB*.exe&set CS=/quiet /norestart /nobackup&goto TOP)
ver | find "5.0" > NUL && (set XT=Windows2000&set CX=Windows2000-KB*.exe&set CS=/quiet /norestart /nobackup&goto TOP)
ver | find "5.2" > NUL && (set XT=Windows2003&set CX=WindowsServer2003-KB*.exe&set CS=/quiet /norestart /nobackup&goto TOP)
ver | find "6.0" > NUL && (set XT=WindowsVista&set CX=Windows6.0-KB*.msu&set CS=/quiet /norestart&goto TOP)

然后在此处增加下面内容:

set XT=Office2007_2010
set CX=*.exe
set CS=/quiet /norestart

如果是 Office2003,就这样:

set XT=Office2003
set CX=*.exe
set CS=/q
© 版权声明
THE END
点赞9赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容