简体   繁体   中英

Python Popen fails to run msiexec

I'm trying to install a Windows MSI with Python like this but it fails.

Popen(shlex.split('msiexec.exe /I Z:/osd46271_2020_RC2.msi /L* install.log'))

在此处输入图片说明

The install.log file is created but nothing is written there. The exact same command running in Command Prompt works fine. I'm running as Administrator on Windows 2016 with Python 3.8.2. I have used similar code on the same system in the past. I can't figure out what would be breaking this.

Okay I figured it out already. I have to use four backslashes with shlex.split so it will be turned into two backslashes. This is kind of ugly, but it works.

Popen(shlex.split('msiexec.exe /I Z:\\\\osd46271_2020_RC2.msi /L* install.log'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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