命令行 - 等待进程完成

Jas*_*rke 3 windows batch-file command-line-interface command-line-arguments

我正在无人值守的脚本中安装一组驱动程序。其中一个驱动程序(英特尔 USB3 驱动程序)在完成后启动 Windows 驱动程序查找应用程序(“drvinst.exe”)。然后,当 nVidia 驱动程序尝试运行时,它们会取消,因为该向导仍在后台运行。

我当前的解决方案是这样的,但它不是很优雅:

:INSTALLLAPTOP79
.\ELAN\Touchpad\Setup.exe /s /a /s
.\Intel\Chipset\Setup.exe -s -norestart
.\Intel\Graphics\Setup.exe -s
.\Intel\MEI\Setup.exe -s
.\Intel\USB3\Setup.exe -s
.\Realtek\Audio\Setup.exe /s
.\Realtek\CardReader\Setup.exe /s
TIMEOUT 180
.\nVidia\Graphics\Setup.exe -n -s
GOTO :INSTALLLAPTOPWIFI
Run Code Online (Sandbox Code Playgroud)

基本上,如果系统比“正常”慢,它就会失败,因为 180 秒还不够。我可以增加这个值,但这对我来说很混乱。

我基本上正在寻找一种方法来进行“检查”以查看“drvinst.exe”是否仍在运行,如果是,则等待一段时间 - 然后再次进行检查。

有任何想法吗?

Tri*_*und 5

不保证它可以工作(这取决于安装程序如何启动驱动程序查找器),但是:

start /wait command...
Run Code Online (Sandbox Code Playgroud)

可能会成功。请注意,如果要执行的命令包含空格,并且需要用双引号引起来,则需要:

start /wait "" "c:\program files\something\..."
Run Code Online (Sandbox Code Playgroud)

否则它将将该命令作为命令提示符的标题。