I am running an msi installer in silent mode and caching logs in the specific file. The following is the command i need to execute.
C:\Program Files\ My Installer\Setup.exe /s /v '/qn /lv %TEMP%\log_silent.log'
I used:
subprocess.Popen(['C:\Program Files\ My Installer\Setup.exe', '/s /v '/qn /lv %TEMP%\log_silent.log''],stdout=subprocess.PIPE).communicate()[0]
to execute the command however it does not recognise the operation and gives error regarding wrong option selected. I have cross-verified and found that the command only works this way.
The problem is very subtle.
You’re executing the program directly. It gets:
Whereas it should be:
In other words, it should receive 5 arguments, not 2 arguments.
Also,
%TEMP%is directly unknown to the program!There are 2 ways to fix this problem:
Calling the shell.
Directly call program (more safer)