2016-12-30 31 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

相關問題