2016-12-30 32 views
0

总的初学者在批处理脚本,我试图做一个批处理文件,检查程序是否在任务管理器中运行。如果应用程序正在运行,请运行更新文件,如果未安装该程序,请安装程序.. Adob​​e Reader作为示例。使用.bat文件安装/更新程序

@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. 

希望你有一些建议或解决方案。 新年快乐:)

+2

你的问题是什么? – aschipfl

回答

0

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

@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是否安装了,请按照本文档中的部分​​:Enterprise Administration Guide for the Adobe® Acrobat Family of Products

简而言之:检查GUID的注册表位置,看后一文件:

的GUID被写入到不同的位置。但是,Adobe 建议您使用以下方法:

  • 32位Windows:
    • HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\{application}\{version}\Installer\
  • 64位Windows:
    • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Adobe\{application}\{version}\Installer\

参考此线程:Check if Adobe Reader is installed

相关问题