Bug->Doc #79704 [Nab->ReO]: proc_open failure with Windows

From: Date: Tue, 16 Jun 2020 08:21:50 +0000
Subject: Bug->Doc #79704 [Nab->ReO]: proc_open failure with Windows
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17650@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79704&edit=1 ID: 79704 Updated by: cmb@php.net Reported by: svnpenn at gmail dot com Summary: proc_open failure with Windows -Status: Not a bug +Status: Re-Opened -Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: Program Execution Operating System: Windows 10 PHP Version: 7.4.7 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Apparently, msiexec.exe does not use the supplied argv[1], but rather GetCommandLine() doing its own parsing of the arguments. Other commands may do this as well, so we should at least document this issue. [1] <https://docs.microsoft.com/en-us/cpp/cpp/main-function-command-line-args?view=vs-2019#parsing-c-command-line-arguments> Previous Comments: ------------------------------------------------------------------------ [2020-06-16 02:46:28] requinix@php.net proc_open() with the $cmd as an array will quote all the arguments. Try running the resultant command yourself: C:\>"C:\Windows\System32\msiexec.exe" "TargetDir=C:\TargetDir" "/qb" "/a" "a.msi" What you need to do is $a = "C:\\Windows\\System32\\msiexec.exe TargetDir=C:\\TargetDir /qb /a a.msi"; The important thing is that you do not quote the TargetDir option or the flags. If the filename is variable then you may quote it (using escapeshellarg) - this works because msiexec specifically supports it. ------------------------------------------------------------------------ [2020-06-16 02:30:42] svnpenn at gmail dot com Description: ------------ proc_open failure with Windows If I run this Python script: import subprocess a = [ r'C:\Windows\System32\msiexec.exe', r'TargetDir=C:\TargetDir', '/qb', '/a', 'a.msi' ] subprocess.run(a) Everything is fine, but if I run this PHP script: <?php declare(strict_types = 1); $a1 = [ 'C:\\Windows\\System32\\msiexec.exe', 'TargetDir=C:\\TargetDir', '/qb', '/a', 'a.msi' ]; $a2 = []; $a3 = []; proc_open($a1, $a2, $a3); I just get the usage page for Windows Installer. The documentation and tests show that you can use an array: - https://github.com/php/php-src/blob/master/ext/standard/tests/general_functions/proc_open_array.phpt - https://www.php.net/manual/en/function.proc-open.php but it seems PHP is doing something funny with the parsing. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79704&edit=1

« previous php.doc.bugs (#17650) next »