Batch Script to wait for program to close by user before applying msi update

守給你的承諾、 提交于 2019-12-08 18:15:28
@echo off

    start "" notepad.exe

:loop
    (tasklist | find /i "notepad.exe" && ( ping -n 2 localhost & goto loop)) >nul 

    echo Notepad closed

This just starts notepad.exe (the running program) and waits until it is closed. Adapt according to your needs

`tasklist |find "programname"` 

will tell you if the programm is running:

if %errorlevel%==0 echo running

put just a little loop around it:

:loop
tasklist |find "programname" >nul
if %errorlevel%==0 (
  echo prgram running
  timeout 2>nul
  goto loop
)
echo program not running
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!