批处理脚本,等待用户关闭程序,然后再应用msi更新 [英] Batch Script to wait for program to close by user before applying msi update

查看:103
本文介绍了批处理脚本,等待用户关闭程序,然后再应用msi更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用网络管理工具将更新应用于软件,但是我遇到一个问题,如果用户已经在使用您要更新的程序,则更新将失败. 我一直在尝试将一个批处理脚本放在一起,以检测程序是否正在运行,如果是脚本,则将等到用户关闭程序并应用msi更新. >

我搜索过很多Google,但是只能真正找到以前的脚本,这些脚本会先杀死程序,然后再继续操作,而且我不希望这种情况发生,因为用户可能会丢失工作.

希望有人可以提供帮助!

解决方案

@echo off

    start "" notepad.exe

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

    echo Notepad closed

这只会启动notepad.exe(正在运行的程序)并等待直到其关闭.根据您的需求进行调整

I'm using a network management tool to apply updates to software and I have an issue where if a users is already using the program you want to update the update will fail as you would expect. I have been trying to put together a batch script that will detect whether the the program is running and if it is the script will wait until the user closes down the program and the apply the msi update.

I've pretty much scoured google but can only really find previous scripts that kill the program first before proceeding and I don't want that to happen as the user may lose work.

Hope someone can help!

解决方案

@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

这篇关于批处理脚本,等待用户关闭程序,然后再应用msi更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆