简体   繁体   English

通过 paramiko 运行 msi 安装程序并等待任务完成

[英]Run msi installer via paramiko and wait for the task to be done

I'm facing on some troubles here.我在这里遇到了一些麻烦。

The wish愿望
a python script that can update a third party software on all my factory machines.一个python脚本,可以更新我所有工厂机器上的第三方软件。

How i'm doing that我是怎么做的
I wrote a python script that's using Paramiko to ssh all the computers, copying required files and running .msi package on any succesfull connection.我编写了一个 python 脚本,它使用 Paramiko 对所有计算机进行 ssh,复制所需的文件并在任何成功的连接上运行 .msi 包。

The problem问题
Well, i'm not finding any way or method in order to wait msi process to be over and getting back any exit code.好吧,我没有找到任何方法或方法来等待 msi 进程结束并取回任何退出代码。 I need to wait until installation is over and obtain a return code beacuse i need to copy hotfix files in x86 program installation directroy.我需要等到安装结束并获得返回码,因为我需要在 x86 程序安装目录中复制修补程序文件。
So, i tried the followings:所以,我尝试了以下方法:

stdin, stdout, stderr = self.client.exec_command("msiexec.exe /a msi_file_name.msi /qn")
stdin, stdout, stderr = self.client.exec_command("start /wait msiexec.exe /a msi_file_name.msi /qn")
stdin, stdout, stderr = self.client.exec_command("msi_file_name.msi /qn")

but noone of the above seems to wait for the installation to be over.但以上似乎都没有等待安装结束。

My question to you guys我对你们的问题
I'm wondering if there's any way to run a msi and make the shell wait for the task to be over.我想知道是否有任何方法可以运行 msi 并使 shell 等待任务结束。 It will be fine both way, via python or via exec_command, using some cmd workaround.使用一些 cmd 解决方法,通过 python 或通过 exec_command 两种方式都可以。

Thanks,谢谢,
Hele赫勒

This is not a Paramiko, nor even a Python question.这不是 Paramiko,甚至不是 Python 问题。 That is a consequence of the /qn switch.这是/qn开关的结果。 With the switch, the top-level msiexec process delegates installation to a hidden subprocess and terminates itself immediately.使用该开关,顶级msiexec进程将安装委托给隐藏的子进程并立即终止自身。

Consider using /qb or /qb!考虑使用/qb/qb! or similar, instead.或类似的,而不是。

See msiexec command-line options .请参阅msiexec命令行选项


Copied from a similar question on Inno Setup:复制自 Inno Setup 上的一个类似问题:
Inno Setup AfterInstall procedure is executed too early, when installing MSI from Run section with /qn (silent) switch Inno Setup AfterInstall 过程过早执行,当从运行部分使用 /qn(静默)开关安装 MSI 时

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM