从PHP运行PowerShell命令以使用参数执行HTA

从PHP运行PowerShell命令以使用参数执行HTA,php,powershell,hta,Php,Powershell,Hta,我有一个Powershell命令,我可以正常运行,如果我从Powershell运行它,它将在远程服务器上执行HTA应用程序。它可以处理0个问题。当我试图在php中通过shell\u exec调用相同的命令时,应用程序会以交互方式启动,但传递的参数没有引号,hta无法识别。我需要帮助弄清楚如何在变量周围传递引号 我还插入了-NoExit,用于故障排除,因此powershell窗口不会关闭 我回显$runCMD2时的另一个注意事项它的格式非常完美,就像我要复制并粘贴到powershell窗口一样 以

我有一个Powershell命令,我可以正常运行,如果我从Powershell运行它,它将在远程服务器上执行HTA应用程序。它可以处理0个问题。当我试图在php中通过
shell\u exec
调用相同的命令时,应用程序会以交互方式启动,但传递的参数没有引号,hta无法识别。我需要帮助弄清楚如何在变量周围传递引号

我还插入了
-NoExit
,用于故障排除,因此powershell窗口不会关闭

我回显
$runCMD2时的另一个注意事项它的格式非常完美,就像我要复制并粘贴到powershell窗口一样

以下PHP代码启动窗口,但不传递2个参数:


    function buildPackage()
                    {
                        $serverName = "\\\\server";
                        $msiName = '"MSI_test_name_goes_here"';
                        $installDir = '"D:\\some\\needed\\path\\"';

                        $runCMD2 = 'start powershell.exe -NoExit psexec -accepteula -s -i 2 '.$serverName.' cmd /c D:\path\to\my.hta '.$msiName.' '.$installDir;
                        echo $runCMD2;
                        $execCMD = shell_exec("$runCMD2");
                        //Begin Building
                        echo "Starting Build...<br>";
                        echo $execCMD;
                        echo "Build Complete";

                    }


函数buildPackage()
{
$serverName=“\\\\server”;
$msiName=''MSI_test_name_goes_here';
$installDir=''D:\\some\\needed\\path\\';
$runCMD2='start powershell.exe-NoExit psexec-accepteula-s-i 2'.$serverName.'cmd/c D:\path\to\my.hta'.$msigname'.$installDir;
echo$runCMD2;
$execCMD=shell_exec($runCMD2”);
//开始建造
回显“开始构建…
”; echo$execCMD; 呼应“构建完成”; }
答案是我需要在每一面加上8个引号!在发布这个问题后,我完全找到了答案


$msiName = '"""""""""MSI_test_name_goes_here"""""""""';
$installDir = '"""""""""D:\\some\\needed\\path\\"""""""""';