Windows 使用.bat文件安装/更新程序

Windows 使用.bat文件安装/更新程序,windows,batch-file,Windows,Batch File,完全是批处理脚本的初学者,我正在尝试创建一个批处理文件,检查一个程序是否在任务管理器中运行。如果应用程序正在运行,请运行更新文件;如果未安装程序,请安装程序。。以AdobeReader为例 @echo off echo Installing Adobe Reader DC 150072033 Base... echo This step will be omitted if it is unnecessary. :B tasklist | findstr /I "AcroRd32.exe" if

完全是批处理脚本的初学者,我正在尝试创建一个批处理文件,检查一个程序是否在任务管理器中运行。如果应用程序正在运行,请运行更新文件;如果未安装程序,请安装程序。。以AdobeReader为例

@echo off
echo Installing Adobe Reader DC 150072033 Base...
echo This step will be omitted if it is unnecessary.
:B
tasklist | findstr /I "AcroRd32.exe"
if errorlevel 1 (call "msiexec /i AcroRdrDC1502020039.msi /qn") ELSE (timeout /t 30)
GOTO :B
echo.
echo Installing Adobe Reader DC Update Patches...
msiexec /p "AcroRdrUpd1502020039.msp" /qn"
echo.
echo Installation concluded.
希望您能提供一些建议或解决方案。
新年快乐:)

也许下一个注释代码片段可以帮助您:

@echo off
echo Installing Adobe Reader DC 150072033 Base...
echo This step will be omitted if it is unnecessary.
:B
rem check if Adobe Reader is currently running not if it's installed
tasklist | findstr /I "AcroRd32.exe"
if errorlevel 1 (
    rem use `start` command instead of `call`
    rem             to ensure that current `bat` waits until `msiexec`'s finish
    start "" /B /WAIT msiexec /i AcroRdrDC1502020039.msi /qn
) ELSE (
    echo please exit Adobe Reader to continue
    timeout /t 30
    rem check again 
    GOTO :B
)
echo.
echo Installing Adobe Reader DC Update Patches...
msiexec /p "AcroRdrUpd1502020039.msp" /qn
echo.
echo Installation concluded.
请注意,
tasklist | findstr/I“AcroRd32.exe”
检查Adobe Reader当前是否运行。要检查是否安装了Adobe Reader,请按照本文档中的部分进行操作:

简而言之:检查GUID注册表位置,请参阅后一个文档:

GUID被写入多个位置。然而,Adobe 建议您使用以下各项:

  • 32位窗口:
    • HKEY\U LOCAL\U MACHINE\SOFTWARE\Adobe\{application}\{version}\Installer\
  • 64位窗口:
    • HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Adobe\{application}\{version}\Installer\

参见本帖:

你的问题是什么?